Reputation: 138
I have been trying to use several conditional statements using is_home/is_front_page or is_single and they are not working in my theme. Below is an example on such code:
<?php if(is_front_page() || is_home() ) : ?>
<?php if(function_exists('show_flexslider_rotator'))
echo show_flexslider_rotator('homepage_fexslider' ); ?>
This loads my Flexslider, but when I go to page 2, the slider remains on the page.
I have used these statements successfully in other themes.
Do I need to add support for this feature in my functions.php?
How can I troubleshoot this?
My home.php code is as follows:
<?php get_header(); ?>
<?php if(is_front_page() || is_home() ) : ?>
<?php if(function_exists('show_flexslider_rotator')) echo show_flexslider_rotator( 'homepage' ); ?>
<?php endif; ?>
<div class="row below-banner">
<div id="site-content" class="span8">
<div class="row">
<div class="span8">
<div class="widget-header">
<h2>What's new</h2>
</div>
</div>
</div>
<div class="row">
<div class="posts span8">
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') :1; query_posts('cat=-35&paged=' . $paged);?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part( 'entry' ); ?>
<?php endwhile; ?>
<?php wp_pagenavi(); ?>
<?php else : ?>
<h2>No Posts Found</h2>
<?php endif; wp_reset_query(); ?>
</div>
</div>
<?php get_footer(); ?>
Upvotes: 0
Views: 863
Reputation: 3993
The issue with wordpress conditionals like is_single is that they don't work outside a functions in functions.php
So the solution is to place the conditional within the function and call that function using add_action probably.
The code here is_single not working in functions.php explained how it won't work outside the function and how should it be instead
Upvotes: 0
Reputation: 831
We would need more info/code in order to give a definitive answer, but my best guess is that you need to add a wp_reset_query() somewhere.
A quick test: add wp_reset_query() immediately before the conditional statements and see if that resolves the issue. If so, then you need to find the offending query and make sure it is reset at the appropriate time.
Upvotes: 1