0

I used to have a page called "Blog" with dummy content (it said "hello world" or similar). Off the menu there was a link to www.mydomain.com/blog and this used to fire up index.php and list recent posts. The hello world content of the blog page never showed up. And in any case, the Blog page was set to Draft.

This was just how I wanted it, even though I couldn't work out how the WordPress loop within index.php was managing to show posts and not the hello world. Here's what the loop looks like in index.php:

 if ( have_posts() ) : while ( have_posts() ) : the_post();
        if (is_search() && ($post->post_type=='page')) continue; ?>
        <div class="box">
         <a href="<?php the_permalink() ?>">
        <h2><?php the_title() ?></a></h2>

The site was running fine. Recently, for not special reason, I noticed that the Blog page still existed albeit set to Draft. To tidy up a bit I figured I'd delete the page. After all it seemingly wasn't required.

As soon as I deleted it, going to www.mydomain.com/blog resulted in a 404. Yikes. I quickly restored the Blog page. It showed "Hello world". I deleted it again. 404. I recreated it as a Draft (in case that was crucial). 404. I published it. Hello World. I cannot get my list of posts back.

I have a complete copy of the site on another server, with the behaviour I wanted to restore (mydomain.com/blog firing up index.php with a list of recent posts). I have reproduced the exact above steps with the same results.

Whatever I try (on either server) I cannot get back to how it was, with mydomain.com/blog firing up index.php with a list of recent posts.

While I concede that whatever setup I had before was fragile and perhaps not the "correct" way to setup a theme, it did work as it stood, and I would love to know how I can restore it, without having to code a new template.

1 Answer 1

0

I can - sort of - solve my problem by cheating.

One of the reasons I don't want to dig around in the code in index.php is that it serves both as a sort of homepage for the blog and also as a search results page (in this site searching through posts is the only kind of search we care about).

So on the menu I can point the href for the Blog link to mydomain.com/?s instead of mydomain.com/blog. This shows the old list of posts and does solve the problem with no coding needed.

But I'd still love to know why it used to work with mydomain.com/blog.

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.