0

I have created a custom theme and my front page is index.php. Moreover, I have couple of blog posts and I display them with a loop in this page, together with a link for each particular post. The problem is that whenever I click on this link, the browser loads the correct permalink, e.g. http://localhost/wordpress/index.php/2016/04/20/title-of-clicked-post/, but the content remains the same.

I use is_front_page() to determine whether I am loading the front page or a single post. When I click on a single post, how to display this post only and not all the others?

  • 1
    WordPress creates the default query on each page automatically based on the requested URL. I'll guess you are probably creating your own query and outputting those results instead of just running the standard loop. – Milo Apr 21 '16 at 1:35
  • 1
    Thanks a lot. This was indeed the case. You can write it as an answer. – Ivaylo Toskov Apr 21 '16 at 1:38
1

WordPress creates the default query on each page automatically based on the requested URL. Your template file should contain the standard loop to output whatever the default query contains.

if( have_posts() ){
    while( have_posts() ){
        the_post();

        the_title();
        the_content();

    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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