Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter [email protected]

    (@sanjeevaggarwalsmb-grcom)

    The code for above is included below:

    [<?php
    $categories = get_the_category();
    echo ‘

    • ‘;
      foreach ($categories as $c) {
      if (strpos(get_permalink($post->ID), $c->slug) !== false) {
      echo ‘<h2><u>slug . ‘/”>’ . $c->name . ‘</u></h2>’;
      $current_cat = $c->cat_ID;
      }
      }
      $posts = get_posts(array(‘cat’ => $current_cat));
      if (!empty($posts)) {
      echo ‘

    ‘;
    }
    echo ‘

    ‘;
    ?>]

    It looks like you figured it out as there are 10 posts in your sidebar. Backticks are ` left of the 1 on keyboard. Or hit CODE button. Post code. Hit CODE button again.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List Posts in a selected category on sidebar’ is closed to new replies.