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
        }
    }

1 Answer 1

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())
 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.