• I have a new blog I am building here https://www.storageworks.biz/blog
    When on a single post page such as https://www.storageworks.biz/blog/6-must-have-tips-for-moving-into-your-first-apartment/ when I go to the bottom and click on the posted in link to view other posts in the same category, it shows me all posts in place of only the one category type.

    How do I set it up to filter out the results?

    My code is as follows,

    <?php get_header(); ?>
    
    <div id='page_wrapper'>
        <div id='page'>
            <div id='slider_wrapper' >
    
                <?php get_sidebar(); ?>
    
                <div id='wrapper_right'>
                    <div id="content">
                        <div id="nav-above" class="navigation">
                            <div class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">«</span> %title' ) ?></div>
                            <div class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">»</span>' ) ?></div>
                        </div><!-- #nav-above -->
                        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                        <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
                            <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                            <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
                            <div class="entry">
                                <?php the_content(); ?>
                            </div>
                            <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php //comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
                        </div>
                        <?php //comments_template(); ?>
                        <?php endwhile; endif; ?>
                        <div id="nav-below" class="navigation">
                        <div class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">«</span> %title' ) ?></div>
                        <div class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">»</span>' ) ?></div>
                        </div><!-- #nav-below -->
                    </div>
                    <div style="clear:both;"></div>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    
        <div class="clear"></div>
    
    <?php get_footer(); ?>
Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi Patrick!

    Is this the code for single.php or archive.php ? Are you using any plugins on your site?

    Also you could try to go to Settings->Permalinks and press “Save Changes” to see if everything checks out there.

    Thread Starter Patrick

    (@xtccat)

    Hi VeVas, my template hierarchy consists of,

    Header
    index
    single
    sidebar
    footer
    functions

    so I believe it is using single. I only have one plugin installed and I already tried disabling it to see if that would help and I got nothing.

    As for the permalinks I went back and reset them to default, saved, did not help and then reset to post name, saved and it did nothing as well.

    No, then it will use index.php (Check out WordPress Template Hiarchy: https://developer.wordpress.org/themes/basics/template-hierarchy/) 🙂

    Try uploading (or duplicating from a standard WordPress Theme) a category.php page to your theme’s folder.

    This is a modified version of twentyfourteens category.php:

    <?php get_header(); ?>
    
    <div id='page_wrapper'>
        <div id='page'>
            <div id='slider_wrapper' >
    
            	<?php get_sidebar(); ?>
    
    			<?php if ( have_posts() ) : ?>
    
    			<div id='wrapper_right'>
                    <div id="content">
                        <div id="nav-above" class="navigation">
                            <div class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">«</span> %title' ) ?></div>
                            <div class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">»</span>' ) ?></div>
                        </div><!-- #nav-above -->
    			<header class="archive-header">
    				<h1 class="archive-title"><?php printf( __( 'Category Archives: %s', 'twentyfourteen' ), single_cat_title( '', false ) ); ?></h1>
    
    				<?php
    					// Show an optional term description.
    					$term_description = term_description();
    					if ( ! empty( $term_description ) ) :
    						printf( '<div class="taxonomy-description">%s</div>', $term_description );
    					endif;
    				?>
    			</header><!-- .archive-header -->
    
    			<?php
    					// Start the Loop.
    					while ( have_posts() ) : the_post();
    				?>
    					<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    						<?php
    							the_title( '<header class="entry-header"><h1 class="entry-title">', '</h1></header><!-- .entry-header -->' );
    						?>
    
    						<div class="entry-content">
    							<?php
    								the_content();
    								wp_link_pages( array(
    									'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfourteen' ) . '</span>',
    									'after'       => '</div>',
    									'link_before' => '<span>',
    									'link_after'  => '</span>',
    								) );
    
    								edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' );
    							?>
    						</div><!-- .entry-content -->
    					</article><!-- #post-## -->
    
    					<?PHP endwhile; ?>
    					</div></div>
    				<?PHP else: 	?>
    					<div id='wrapper_right'>
                    <div id="content">
    					<header class="page-header">
    							<h1 class="page-title"><?php _e( 'Nothing Found', 'twentyfourteen' ); ?></h1>
    						</header>
    
    						<div class="page-content">
    							<?php if ( is_home() && current_user_can( 'publish_posts' ) ) : ?>
    
    							<p><?php printf( __( 'Ready to publish your first post? <a href="%1$s">Get started here</a>.', 'twentyfourteen' ), admin_url( 'post-new.php' ) ); ?></p>
    
    							<?php elseif ( is_search() ) : ?>
    
    							<p><?php _e( 'Sorry, but nothing matched your search terms. Please try again with some different keywords.', 'twentyfourteen' ); ?></p>
    							<?php get_search_form(); ?>
    
    							<?php else : ?>
    
    							<p><?php _e( 'It seems we can&rsquo;t find what you&rsquo;re looking for. Perhaps searching can help.', 'twentyfourteen' ); ?></p>
    							<?php get_search_form(); ?>
    
    							<?php endif; ?>
    						</div><!-- .page-content -->
    					</div>
    				</div>
    			<?PHP endif; ?>
    			?>
    </div></div></div>
    
    <?php
    get_footer();

    Thread Starter Patrick

    (@xtccat)

    I had tried that as well. Placed category.php with the same code from above within it and no change. I also just took the coed from your post, and placed it into category.php to see if it would do anything and nothing.

    Ok, how does your index.php file look?

    Just for testing purposes(!). Try putting this before if ( have_posts() ) in your index file:
    <?PHP query_posts(‘cat=INSERT_ID_OF_MOVING_TIPS_CATEOGRY’); ?>

    Thread Starter Patrick

    (@xtccat)

    index.php and category.php are basically identical. I place your bit of code where you mentioned with the correct category and it worked. All I see is the post from that category.

    Ok, then it is something messing with your query. Do you know of anything that might do that in maybe the functions.php file or somwhere else in your theme? You might also try to change theme to a standard wordpress theme to see if it works then.

    Thread Starter Patrick

    (@xtccat)

    functions.php is rediculously simple

    <?php // custom functions
    
    add_theme_support( 'post-thumbnails' );
    if(has_post_thumbnail()) {
        $image_src = wp_get_attachment_image_src( get_post_thumbnail_id(),'full' );
         echo '<img src="' . $image_src[0]  . '" width="100%"  />';
    } 
    
    // Replaces the excerpt "more" text by a link
    function new_excerpt_more($more) {
           global $post;
    	return '&nbsp;<a class="moretag" href="'. get_permalink($post->ID) . '">read more...</a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
    
    ?>

    I tried switching themes and yes, it worked. This is frustrating. I’m not sure what it could be. My template is so simple you is causing such a big issue.

    Yes. Maybe it’s to simple, something might be missing 🙂

    Hard to say what i might be excactly. You have a sidebar listing all your posts, try disabling the recent posts widget. You might also try putting this: <?php wp_reset_query(); ?> at the end of your sidebar.php.

    There are some ways to debug Wp_Query, search the forum and google.

    Thread Starter Patrick

    (@xtccat)

    Hey VeVas, your last post did the trick. Added <?php wp_reset_query(); ?> to the bottom of sidebar.php and everything works as it should now. Thank you so much for your help!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘When clicking on posted in link, categories aren't filtering’ is closed to new replies.