Pages?

  • Anonymous

    #17696

    Syahir.

    Yes, that’s exactly what I was looking for. Thank you. So, would it work in a function like this to NOT display it on the front page?

    function josh_followme(){
    if ( !is_front_page() ){
    ?>
    <div id="followme"><img src="http://www.joshlobe.com/wp-content/images/follow.png"></div>
    <?php
    add_action( 'graphene_feed_icon', 'josh_followme' );
    }
    }

    I read somewhere that by inserting the exclamation point, it is an exclude. The way I understood it, is that using the exclamation will have it appear everywhere EXCEPT the front page.

    I’m just wondering if the syntax is correct?

    Admin

    Syahir Hakim

    #17697

    No, that function would not be displayed anywhere at all, since the add_action() function will never be executed unless you explicitly call the josh_followme() function.

    You should do it like this instead:

    function josh_followme(){
    if ( !is_home() ){
    ?>
    <div id="followme"><img src="http://www.joshlobe.com/wp-content/images/follow.png"></div>
    <?php
    }
    }
    add_action( 'graphene_feed_icon', 'josh_followme' );

    Note that the add_action() function does not execute the josh_followme() function when it is called. It merely places the function into the function queue, so that when the graphene_feed_icon action is run, then those functions in the queue will be executed. And by the time graphene_feed_icon action is run, WordPress will already know what page it is serving, hence the is_home() conditional will work as intended.

    As for the exclamation point, that is a PHP syntax (commonly used by other programming languages as well) to denote NOT. So for example, if is_home() returns true, putting ! is_home() will evaluate to NOT true, meaning false.

    Also, make sure you know the difference between is_home(), which is for the posts listing page, and is_front_page(), which is for the site’s front page regardless of whether or not it’s a posts listing page or a static front page.

    Anonymous

    #17698

    Thank you so much for the detailed explanation, my friend. As always, you are extremely helpful and concise.

    A million thank you’s.

Viewing 3 posts - 61 through 63 (of 63 total)

  • You must be logged in to reply to this topic.
Graphene Themes Forum