• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Conditional tags not working in functions php

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Conditional tags not working in functions php

This topic is: not resolved

Tagged: conditional tags, home

  • This topic has 11 replies, 2 voices, and was last updated 11 years, 1 month ago by Askitbasket.
Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • October 21, 2014 at 10:00 am #128656
    Askitbasket
    Member

    Hi everyone

    I have two "if ( is_home() )" conditional tags in my functions.php, one to remove the post navigation and another to display my posts in three columns.

    Here's an example:

    `add_action ( 'genesis_after_entry', 'sk_remove_pagination' );
    function sk_remove_pagination() {
    if ( is_home() ) {

    remove_action( 'genesis_after_endwhile', 'genesis_posts_nav' );

    }
    }

    ...For some reason they are effecting the whole site rather than just the home.

    Does anybody have an idea how to fix this?

    http://www.vetschoolscouncil.ac.uk
    October 21, 2014 at 10:13 am #128657
    Brad Dalton
    Participant

    What theme?


    Tutorials for StudioPress Themes.

    October 21, 2014 at 11:20 am #128668
    Brad Dalton
    Participant

    If your theme includes a front-page.php or home.php file, you can add the code directly in the file before the closing genesis(); tag.

    remove_action( 'genesis_after_endwhile', 'genesis_posts_nav' );
    

    Tutorials for StudioPress Themes.

    October 21, 2014 at 12:54 pm #128673
    Askitbasket
    Member

    Hi Brad, thanks for the reply.

    The theme is Education Pro and it includes 'front-page.php'.

    ...If I include your above code in that file, I assume I'll need to remove the code that I had added to the functions.php file? What can I do about the three column posts display which I am trying to confine to the home page?

    October 21, 2014 at 8:53 pm #128706
    Brad Dalton
    Participant

    Yes, only use it in the front page file.

    Multiple options for columns.

    I would filter the post class conditionally using the is_home conditional tag


    Tutorials for StudioPress Themes.

    October 22, 2014 at 1:31 am #128726
    Askitbasket
    Member

    Thanks Brad, that is what I have done for the columns, but it is not being restricted to the home page. I have other pages set up to display custom post types that are ending up in three columns with this method.

    Here is the code I put in at the end of functions.php

    add_filter( 'post_class', 'ca_home_post_column_class' );
    
    function ca_home_post_column_class( $classes ) {
    if (is_home() ) {
    global $wp_query;
    $classes[] = 'one-third';
    if ( $wp_query->current_post % 3 === 0 )
    $classes[] = 'first';
    }
    return $classes;
    }
    October 22, 2014 at 2:06 am #128729
    Brad Dalton
    Participant

    Home page is your posts page or blog page try is_front_page()


    Tutorials for StudioPress Themes.

    October 22, 2014 at 2:06 am #128730
    Brad Dalton
    Participant

    Whats your email address?


    Tutorials for StudioPress Themes.

    October 22, 2014 at 2:22 am #128731
    Askitbasket
    Member
    This reply has been marked as private.
    October 22, 2014 at 5:48 am #128737
    Brad Dalton
    Participant

    Edward

    Read the forum rules regarding copyright.

    You are showing disrespect for fellow members and violating copyrights.


    Tutorials for StudioPress Themes.

    October 22, 2014 at 7:12 am #128741
    Askitbasket
    Member

    Hi Brad

    Sorry, I don't understand what you mean ...Did you post that in the wrong thread by mistake?

    October 23, 2014 at 2:54 am #128829
    Askitbasket
    Member

    I tried is_front_page() and it didn't work by the way

  • Author
    Posts
Viewing 12 posts - 1 through 12 (of 12 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble