If you ever tried to use an if statement because you wanted to remove an action on a specific page, you would have noticed that it doesn’t work! Why? Because you can’t just start writing if statements in your functions.php file. It has to be tied to an action.
Here’s a simple way to do this with the Genesis Framework.
In my case, I needed one of my post type pages to look a certain way. I could have used is_single but then ALL of my single pages would have been effected!
Here’s what I tried at first:
Everything seemed OK, but it didn’t work??
Well, it was then that I realized in order to use an if statement like this, it has to be in a function. Your functions.php file won’t read this little bit code.
So what action am I supposed to add it to?
The key here is to remember that we’re editing the loop. The post_meta and post_info are all within the loop of the page.
So if we want to manipulate it, we have to add our action to anything that comes before the loop.
Well, being that Genesis is so freaking awesome and has TONS of hooks you can use, I decided to use the one that makes the most sense.
And voilà! Now the remove_action function will only work on the single post type pages!!
Genesis 2.0 Version NEW
Are you using Genesis 2.0? If so, then this is the code you would use.