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.
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’t find what you’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();
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’); ?>
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.
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 ' <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.
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!