最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

get post - Custom field in PHP file

programmeradmin2浏览0评论

im a beginner with PHP, so i hope that someone can help me solving this issue.

I want to display the expiration date of a post with the following plugin /

I've think i can use: $hasp_expire_date = get_post_meta( $post_id, ‘hasp_expire_date’, true );

But i don't know how to insert it into a php file. I need to place in this code (Where it says CODE HERE):

                $num_comments = get_comments_number( $block_data['id'] );
                $entry_comments = 'CODE HERE<i class="fa fa-speech-bubble"></i><span>'.$num_comments.' '._nx( 'Comment', 'Comments', $num_comments, 'comments', 'uncode' ).'</span>';

im a beginner with PHP, so i hope that someone can help me solving this issue.

I want to display the expiration date of a post with the following plugin https://wordpress/plugins/advanced-schedule-posts/

I've think i can use: $hasp_expire_date = get_post_meta( $post_id, ‘hasp_expire_date’, true );

But i don't know how to insert it into a php file. I need to place in this code (Where it says CODE HERE):

                $num_comments = get_comments_number( $block_data['id'] );
                $entry_comments = 'CODE HERE<i class="fa fa-speech-bubble"></i><span>'.$num_comments.' '._nx( 'Comment', 'Comments', $num_comments, 'comments', 'uncode' ).'</span>';
Share Improve this question asked Nov 5, 2019 at 11:55 JustifieldJustifield 1
Add a comment  | 

1 Answer 1

Reset to default 0

Assuming your $hasp_expire_date = get_post_meta( $post_id, ‘hasp_expire_date’, true ); is giving you the correct value you need, you are storing your that in the $hasp_expire_date variable.

So edit that second line to:

$num_comments = get_comments_number( $block_data['id'] );

// Pull in the value you need
$hasp_expire_date = get_post_meta( $post_id, ‘hasp_expire_date’, true );

// You are going to concatenate or add that value to your string.
$entry_comments = $hasp_expire_date.'<i class="fa fa-speech-bubble"></i><span>'.$num_comments.' '._nx( 'Comment', 'Comments', $num_comments, 'comments', 'uncode' ).'</span>';

Hope that helps!!

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论