• Resolved Guido

    (@guido07111975)


    Hi,

    Via Settings > Reading I can set a static page for homepage and blogpage.

    I use this in header.php to determine whether a frontpage and/or blogpage is loaded or not:

    <?php if( is_home() || is_front_page() ) {?>
      // header image and header widgets are loaded
    <?php } ?>

    When I set a static blogpage I don’t want to display header image and header widgets.. With code above they are. But what should I add above?

    Did not found the answer here unfortunately.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Guido,

    Can you give this a try:

    <?php if( is_home() || is_front_page() ) {?>
    
    	<?php if( get_option('show_on_front') == 'page' ) : ?>
    		<!-- This is a 'static page' display -->
    	<?php else : ?>
    		<!-- This is a 'latest posts' display -->
    	<?php endif; ?>
    
    <?php } ?>

    The option get_option('show_on_front') might help you on this..

    Samuel.

    Thread Starter Guido

    (@guido07111975)

    Hi Samuel,

    Thanks. Did now know about show_on_front.

    Did a test with this, setting a static Front page and a static Posts page. The same result for both pages, but that’s not what I want:

    In case of static Front page: header image and header widgets
    In case of static Posts page: no header image and no header widgets

    Any further ideas? Maybe a tweak of this code?

    Guido

    Moderator bcworkz

    (@bcworkz)

    Good thought, but ‘show_on_front’ is a static setting, it does not change depending on the request. It does influence how is_home() and is_front_page() works though. If ‘show_on_front’ is set to ‘page’, you can use is_home() or is_front_page() alone to test for which page is loaded. The problem arises when you use both.

    Trying to explain this is likely to get confusing, instead I refer you to the examples on Function_Reference/is_home. Thus this should work on you site:

    <?php if( is_front_page() ) : ?>
       <!-- This is a 'static page' display -->
    <?php else : ?>
       <!-- This is a 'latest posts' display -->
    <?php endif; ?>

    BTW Guido, your posts page is not static, only your front page is. I do understand how you came to apply ‘static’ to your posts page – the reading settings layout would lead you to believe both are static. Just a minor point and too pedantic for many people, so don’t worry about it. Anyway, the posts page is dynamic because the main content changes depending on what the latest blog posts are. The front page is static because the main content is what is entered on the edit screen and does not normally change based on other influences like blog posts. Just sayin’ ??

    Thread Starter Guido

    (@guido07111975)

    Hi BC,

    And once again you’ve fully answered my question :-).
    Only remove the is_home part does the trick, great.

    Thanks man!

    Guido

    ps. unfortunately I’ve just updated my themes several hours ago.. so this will be added to the next version

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Static blog page without same header as frontpage’ is closed to new replies.