Don’t Worry, You’re In The Right Place
A lot of these posts were originally on So if you found them through search engines or clicking around, this is their new home :). Enjoy!

How to use remove_action with conditional tags

This section is Pre-Genesis 2.0, below is the Genesis 2.0 version. This is also one of the most useful code snippets you will ever use with Genesis.

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.

The Problem

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 Solution

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!!

NOTE: If you’re a WP Types and Views user, this method is essential to creating single page views with your custom post types, if you’re looking to remove the post meta and post info!

Genesis 2.0 Version NEW

Are you using Genesis 2.0? If so, then this is the code you would use.

About the Author
What's UP! This is my site, I write 99% of the articles on here. I'm also the owner of I help out a lot of developers and designers getting into the web game. Helping is fun for me, so feel free to ask me any questions! I've made courses and have a membership as well to help get you on your feet!

12 comments on How to use remove_action with conditional tags

  1. Carrie Dils says:

    “Well, it was then that I realized in order to use an if statement like this, it has to be in a function.” – Great point, Jon. That one took me awhile to understand/figure out. Nice post!

  2. John Cole says:

    Great. Thanks for this. Just what I was looking for.

  3. Thanks for posting this! I forgot about this and was having a tough…this was just what I needed!

  4. Lucas says:

    “This is also one of the most useful code snippets you will ever use with Genesis.” — You have no idea. I’m working on my first genesis site (custom theme from Framework) and I have been bashing my head against the wall for three days with this problem with no help from forums or google. And then I found your post. Thank-you!!

    1. Jonathan says:

      Glad you found the post!! =D Yeah, I use this pretty much on every project I work on so it’s definitely one of those invaluable pieces of information. If there’s anything else you’re interested in learning, just let me know

  5. TJ Greene says:


    Thanks so much for the Genesis 2.0 code. I’ve been searching and tweaking for hours trying to get this right and your code worked perfectly straight away.

    1. Jonathan says:

      Great!! Glad it helped you =)

  6. Derek says:

    Thanks! Really useful post, I adapted it to what I needed easily.

    1. Jonathan says:

      Glad you like it!

  7. thomas chang says:

    Thanks. I take note and will use it in my work.

    1. Jonathan Perez says:

      That’s a winning move sir! 😉

  8. Lord says:

    Thank you! Been pulling my hair and finally found a solution lol

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top