Community Forums › Forums › Archived Forums › Design Tips and Tricks › Conditional tags not working in functions php
Tagged: conditional tags, home
- This topic has 11 replies, 2 voices, and was last updated 11 years, 1 month ago by
Askitbasket.
-
AuthorPosts
-
October 21, 2014 at 10:00 am #128656
Askitbasket
MemberHi 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.ukOctober 21, 2014 at 10:13 am #128657Brad Dalton
ParticipantOctober 21, 2014 at 11:20 am #128668Brad Dalton
ParticipantIf 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' );
October 21, 2014 at 12:54 pm #128673Askitbasket
MemberHi 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 #128706Brad Dalton
ParticipantYes, 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
October 22, 2014 at 1:31 am #128726Askitbasket
MemberThanks 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 #128729Brad Dalton
ParticipantOctober 22, 2014 at 2:06 am #128730Brad Dalton
ParticipantOctober 22, 2014 at 2:22 am #128731Askitbasket
MemberThis reply has been marked as private.October 22, 2014 at 5:48 am #128737Brad Dalton
ParticipantEdward
Read the forum rules regarding copyright.
You are showing disrespect for fellow members and violating copyrights.
October 22, 2014 at 7:12 am #128741Askitbasket
MemberHi 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 #128829Askitbasket
MemberI tried is_front_page() and it didn't work by the way
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.