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

the content - Is there a difference in usage of the_title() and the_content()

programmeradmin1浏览0评论

I try to learn some basics about WP so I pasted the following code into a WP page where I use a plug-in that allows me to write PHP.

It works for the_title (twice), but when I put the_content inbetween, the page hangs with no output. I must comment the_content to make the page print the_title (twice). Different efforts give the same result: the_content() hangs the page but not the_title().

What do I do wrong using the_content.

Sorry that I have not got the formatting perfect. br1 are break tags enclosed in tags to stop php interpretation

$args = array(
    'post_type' => 'post'
);

$post_query = new WP_Query($args);

if($post_query->have_posts() ) {
    while($post_query->have_posts() ) {
        $post_query->the_post();
            the_title();
            br1
            // the_content();
            br1
            the_title();
            br1br1
        }
    }

I try to learn some basics about WP so I pasted the following code into a WP page where I use a plug-in that allows me to write PHP.

It works for the_title (twice), but when I put the_content inbetween, the page hangs with no output. I must comment the_content to make the page print the_title (twice). Different efforts give the same result: the_content() hangs the page but not the_title().

What do I do wrong using the_content.

Sorry that I have not got the formatting perfect. br1 are break tags enclosed in tags to stop php interpretation

$args = array(
    'post_type' => 'post'
);

$post_query = new WP_Query($args);

if($post_query->have_posts() ) {
    while($post_query->have_posts() ) {
        $post_query->the_post();
            the_title();
            br1
            // the_content();
            br1
            the_title();
            br1br1
        }
    }
Share Improve this question edited Dec 27, 2020 at 5:23 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Dec 27, 2020 at 4:41 cvrcvr 1135 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

We can drop this question, please. The page probably loops when it lists itself. I must just find a way to exclude listing itself. Sorry.

This is what was missing

$args = array(
'post_type' => 'post',
'post__not_in' => array(get_the_ID())
 );
发布评论

评论列表(0)

  1. 暂无评论