Pages?
-
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?
AdminNo, that function would not be displayed anywhere at all, since the
add_action()
function will never be executed unless you explicitly call thejosh_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 thejosh_followme()
function when it is called. It merely places the function into the function queue, so that when thegraphene_feed_icon
action is run, then those functions in the queue will be executed. And by the timegraphene_feed_icon
action is run, WordPress will already know what page it is serving, hence theis_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, ifis_home()
returnstrue
, putting! is_home()
will evaluate toNOT true
, meaning false.Also, make sure you know the difference between
is_home()
, which is for the posts listing page, andis_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.Thank you so much for the detailed explanation, my friend. As always, you are extremely helpful and concise.
A million thank you’s.
- You must be logged in to reply to this topic.