lundi 29 décembre 2014

Only the latest post shows up on post page?


disclaimer: this is my first foray into wordpress


I'm creating a custom theme and in the single.php file, i have the main loop, however if i navigate to different posts, all that shows up is the latest post. I could go to the different permalinks, but the only post that shows up is the latest one. How do I make it so that the correct post shows up?


I tried changing the permalinks and deleting and adding pages, but I get the same result.

Here is single.php



<?php while(have_posts()): the_post();?>

<section class="main-section">
<header>
<h1 class="section-header"><?php the_category('/');?></h1>
<ul class="section-nav">
<?php
$cat = get_the_category()[0];
$categoryPosts = get_posts(array('category' => $cat->term_id));

foreach($categoryPosts as $post): setup_postdata($post);
?>

<li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>

<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
</ul>
</header>
<h2 class="section-blurb"><?php the_title();?></h2>
<div class="info">
<?php the_content(); ?>
</div>
</section>

<?php endwhile;?>


Everything works..but only for the latest post.


Edit:

I reinstalled wordpress fresh and made new pages, but the result is the same. I even stripped the code down to just


<?php the_title(); ?>


in the single.php file, but the result is the same. No matter which post you're supposed to be viewing, it only shows the latest post.





Aucun commentaire:

Enregistrer un commentaire