0

I have been successfully using a static front page on a theme I am building (locally so can't share URL) without any issues. Suddenly it has stopped working and I can't work out why. I now see a blank page instead of my blog category posts.

The last change I made between it working and breaking was to add a <?php else: ?> statement into my index.php along with &! is_front_page() into the if statement so that I can show different content on my static home page.

index.php:

<?php get_header(); ?>
<div id="content">
        <?php if ( have_posts() &! is_front_page() ) : ?>
            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>
                <?php get_template_part( 'posts', get_post_format() ); ?>
            <?php endwhile; ?>
        <?php else: ?>
            This is the front page!
        <?php endif; // end have_posts() check ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

I have tried reloading the permalinks page, and re-creating the Home static page and setting it up in the Reading settings page, but nothing seems to resolve the issue.

I have obviously removed the lines I added too, but that didn't resolve the issue either!

My permalink settings are set to postname and category base as . to remove the category part from the URL (again this was working previously). If I remove the category base, then the category works, but the URL is wrong then.

Going to the blog static page I am getting:

is_front_page() = false
have_posts() = false

Hope that all makes sense! Using Wordpress 3.9.1 -- I am relatively new to Wordpress and learning themes which is why its not live. Let me know if there is any other code/settings that you would need to know! I am also using custom post types with custom taxonomies using hierarchical taxonomies.

UPDATE:

I found this page that guides to do what I wanted to do, and I had to put the permalink to /%category%/%postname%/ instead of just /%postname%/ and that has got it working again.

However, I set up a new wordpress site on the same computer with a different URL and copied my theme to it, along with creating the relevant files and the existing method I was using worked there. I'm very puzzled now :/

UPDATE 2:

So when I refreshed the permalinks on the 2nd site, it broke the blog url... so I guess this is the solution!

1

It's more like:

<?php if ( have_posts() &! is_front_page() ) : ?>

this line should be:

<?php if ( have_posts() && !is_front_page() ) : ?>
  • Thanks for the reply, although my if statement works, so I don't need to change it. Having said that, this question is about why the \blog\ static page of my wordpress theme stopped working not about the if statement. – neildeadman Jun 7 '14 at 14:43
  • Could you provide more information about "static page stopped working"? What exact error are you facing? – тнє Sufi Jun 7 '14 at 14:51
  • It loads index.php but because have_posts is false, it doesn't show the blog posts. It was working before and if I remove the category base (i.e. '.') then it works with a url like www.example.com/category/blog/ -- so it doesn't work like www.example.com/blog/ and it did until the change above. – neildeadman Jun 7 '14 at 14:58

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.