Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Custom Menu Widgets Disappearing on Category and Archive Pages WordPress

  • SOLVED

Hi,

My custom menu widgets (the widget built into WP) come up completely empty when the widget is put in the footer of my site. This ONLY occurs on <strong>category</strong> and <strong>archive</strong> pages. What's interesting is that it does display the widget title. It just doesn't display the menu items below that.

I did follow a solution when my custom menus weren't working on category and archive pages. That solution is listed here:

http://wordpress.stackexchange.com/questions/101547/custom-menu-widgets-disappearing-on-category-pages/103096#103096

But the person who wrote that post is also having the same issue as me - with the custom menu widget.

I've tried deactivating all plugins with no success. I'm working in WordPress 3.5.1. I'm including my category.php and footer.php code below:

<strong>Category.php</strong>


<?php get_header(); ?>
<script type="text/javascript">
jQuery("body").removeClass("archive"); // Remove archive class from body
</script>
<div class="clear"></div>
<div class="container_16" >
<div class="grid_4">
<?php include (TEMPLATEPATH . '/includes/sidebar-menu.php'); ?>
<?php include (TEMPLATEPATH . '/includes/sidebar-archive-list.php'); ?>
</div>
<div class="grid_12">
<div class="content stories">
<div class="breadcrumb">
<?php if(function_exists('bcn_display'))
{
bcn_display();
}?>
</div>
<h1 class="page-title"><?php printf( __( 'Category Archives: %s', 'toolbox' ), '<span>' . single_cat_title( '', false ) . '</span>' );?></h1>
<p><?php echo category_description( ); ?> </p>
<?php while ( have_posts() ) : the_post(); ?>
<div class="grid_6 <?php my_post_class(); ?>">
<a href="<?php echo get_permalink(); ?>">
<?php
$gh_category_image = array(
'class' => "featured story-image",
);
?>
<?php if ( has_post_thumbnail() ) {
echo get_the_post_thumbnail($post_id, 'category-image', $gh_home_feature_image);
} else { ?>
<img src="<?php echo $data['gh_default_thumb']; ?>" />
<?php } ?>
</a>
<h1 class="story-title"><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h1>
<p class="story-excerpt"><?php global $more; $more = 0;?><?php $excerpt_content = get_the_content(''); echo gh_strip_content_tags($excerpt_content); //Strip images ?></p>
<p class="post-date"><?php the_time('F jS, Y') ?></p>
</div>

<?php endwhile; ?>

<div class="clear"></div>
<div style="height: 20px; width: 100%;"></div>

<?php kriesi_pagination(); ?>

</div><!--End Posts -->
</div>
</div>
<?php get_footer(); ?>


<strong>Footer.php</strong>


<?php wp_reset_query(); ?>
<div class="clear"></div>
<div id="footer">
<div class="container_16" >
<div id="footer-inner">
<div class="grid_4">

<?php dynamic_sidebar( 'footer-left-sidebar' ); ?>

</div>
<div class="grid_4">
<?php dynamic_sidebar( 'footer-middle-left-sidebar' ); ?>
</div>
<div class="grid_4">
<?php dynamic_sidebar( 'footer-middle-right-sidebar' ); ?>
</div>
<div class="grid_4">
<?php dynamic_sidebar( 'footer-right-sidebar' ); ?>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<div class="footer-clear"></div>
<div id="footer-bottom">
<div class="container_16" >
<div id="copyright">

</div>
</div>
</div>
<div id="footer-logo">
</div><!-- End Footer -->
<?php wp_footer(); ?>
</body>
</html>


Thanks so much for your help!

Answers (5)

2013-06-16

Abdelhadi Touil answers:

Hi
You said the problem is only on archive and category pages, so it's ok on single post etc..
Can you please show us your single.php code?
For your category code, I don't know why there is no <?php if (have_posts()) : ?> statement, nor "else" for "not found" page.. I think your category and archive code isn't as it should be.
I also think there is no need to <?php wp_reset_query(); ?> code..


brandonpence comments:

Abdelhadi,

Thank you for your response. I've added the <?php if (have_posts()) : ?> statement and still no luck. Here is my updated <strong>category.php</strong> file:



<?php get_header(); ?>
<script type="text/javascript">
jQuery("body").removeClass("archive"); // Remove archive class from body
</script>
<div class="clear"></div>
<div class="container_16" >
<div class="grid_4">
<?php include (TEMPLATEPATH . '/includes/sidebar-menu.php'); ?>
<?php include (TEMPLATEPATH . '/includes/sidebar-archive-list.php'); ?>
</div>
<div class="grid_12">
<div class="content stories">
<div class="breadcrumb">
<?php if(function_exists('bcn_display'))
{
bcn_display();
}?>
</div>
<h1 class="page-title"><?php printf( __( 'Category Archives: %s', 'toolbox' ), '<span>' . single_cat_title( '', false ) . '</span>' );?></h1>
<p><?php echo category_description( ); ?> </p>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="grid_6 <?php my_post_class(); ?>">
<a href="<?php echo get_permalink(); ?>">
<?php
$gh_category_image = array(
'class' => "featured story-image",
);
?>
<?php if ( has_post_thumbnail() ) {
echo get_the_post_thumbnail($post_id, 'category-image', $gh_home_feature_image);
} else { ?>
<img src="<?php echo $data['gh_default_thumb']; ?>" />
<?php } ?>
</a>
<h1 class="story-title"><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h1>
<p class="story-excerpt"><?php global $more; $more = 0;?><?php $excerpt_content = get_the_content(''); echo gh_strip_content_tags($excerpt_content); //Strip images ?></p>
<p class="post-date"><?php the_time('F jS, Y') ?></p>
</div>

<?php endwhile; ?>

<?php else : ?>

<h2>Nothing found</h2>

<?php endif; ?>

<div class="clear"></div>
<div style="height: 20px; width: 100%;"></div>

<?php kriesi_pagination(); ?>

</div><!--End Posts -->
</div>
</div>
<?php get_footer(); ?>



Per your request, here is my <strong>single.php</strong> file:



<?php get_header(); ?>
<div class="clear"></div>
<div class="container_16" >
<div class="grid_4">
<?php include (TEMPLATEPATH . '/includes/sidebar-menu.php'); ?>
<?php include (TEMPLATEPATH . '/includes/sidebar-archive-list.php'); ?>
</div>
<div class="grid_12">
<div class="content">
<div class="breadcrumb">
<?php if(function_exists('bcn_display'))
{
bcn_display();
}?>
</div>
<h1 class="page-title post-meta"><?php the_title(); ?></h1>
<p class="post-meta">Posted on <?php the_time('F jS, Y') ?> | Filed Under: <?php the_category(', ') ?></p>
<div class="gh-entry">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content( ); ?>
<?php endwhile; ?>
<?php endif; ?>
<div class="post-completion">
<div class="left">
<?php if (get_adjacent_post(true, '', true)):?>
<div class="btn">
<?php previous_post_link('%link', '&laquo; Previous Post', TRUE); ?>
</div>
<?php endif; ?>
<?php if (get_adjacent_post(true, '', false)):?>
<div class="btn">
<?php next_post_link('%link', 'Next Post &raquo;', TRUE); ?>
</div>
<?php endif; ?>
</div>
<div class="right">
<div class="btn">More <?php the_category(', ') ?></div>
</div>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<?php get_footer(); ?>



Like I said, if I remove <?php wp_reset_query(); ?> from the footer than the custom menu widget doesn't work on any page.


Abdelhadi Touil comments:

Can you send me you theme to try it on my localhost and try to fix the problem?


brandonpence comments:

What's the best way to do this? The theme includes a lot of plugins that would also need to be included.


Abdelhadi Touil comments:

you can send it to me zipped via email..

2013-06-16

Arnav Joy answers:

try one thing , place widget in category.php at top or after get_header function and see if that works , try it


brandonpence comments:

Okay tried that as well with the same result. Widget title comes through but not the menu list.

2013-06-16

isp_charlie answers:

add this before call Widget.

<?
$wp_query = NULL;
$wp_query = new WP_Query(array('post_type' => 'post'));
?>


brandonpence comments:

@isp_charlie,

That did it! Could you explain a bit more of what's going on here for future reference and to help others?

2013-06-16

Yakir Sitbon answers:

Why have this line in footer.php ?
<?php wp_reset_query(); ?>


brandonpence comments:

If I remove that line, then the custom menu widget doesn't work on any page.

2013-06-17

Remy answers:

Did you set WP_DEBUG to true in your wp-config, to see if any php error exists ?