• I am using the code shown to generate a list of all the single posts in a specific category, and it is working great.

    <div class="otherarticles"><p>All Articles in this series:</p>
    <ul><?php
     global $post;
     $myposts = get_posts('category=7');
     foreach($myposts as $post) :
     ?>
        <li><a href=<?php the_permalink(); ?>><?php the_title(); ?></a></li>
     <?php endforeach; ?></ul>
    </div>

    what id like to have happen is that everytime a viewer is viewing a single post (thus using the single.php template) the code automaticly updates the category number generatign that code to match the category that single post is in. The only way I am able to achive this at this time is to create separate single-#.php files and use a conditional script on the single to redirect to that file, but that is a lot of work to change just one measly number in a file.

    surely there is a very simple way to get what im wanting through some kind of code rather than a plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter 741858

    does no one know if this is possible?

    Thread Starter 741858

    Guys I really need the help, i found this code:

    `
    <?php echo $post->ID; ?>’

    and if i insert it on it’s own, it does exactly what I want, it echos the Cat # of the current single post, but if I use it like this:

      <?php
      global $post;
      $myposts = get_posts(‘category=<?php echo $post->ID; ?>’);
      foreach($myposts as $post) :
      ?>
    • ><?php the_title(); ?>
    • <?php endforeach; ?>

      It just shows all posts, ALL posts, not all posts in a single category. What gives?

    Not sure but try this bit of code

    ‘<?php
    $postlist = get_posts(‘category=’. get_the_category());
    foreach ($postlist as $post) : ?>’

    Thread Starter 741858

    thanks for the help spoutnik, but thats listing a display of all posts.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Determine and echo cat # of single post’ is closed to new replies.