[catlist] in PHP not working correctly
-
When I run the following code on a page with the slug ‘pta’, the catlist shortcode functions correctly:
<?php if( is_page('pta')): ?><br><br><h2>PTA News</h2>[catlist name="pta" date="yes"]<?php endif;?>
However, when I replace it with the following code, on the same page, the catlist shortcode does not provide a filtered list but instead outputs a list of ALL recent posts:
<?php $categories = get_categories(); global $post; $post_slug = $post->post_name; foreach ($categories as $category) { $category_slug = $category->slug; $category_name = $category->name; if ($category_slug == $post_slug) { echo ('<br><br><h2>' . $category_name . ' News</h2>'); echo do_shortcode ('[catlist name="' . $category_slug . '" date="yes"]'); } } ?>
Is this a bug or something I’m doing wrong?
Any and all assistance appreciated.Thanks!
Chris
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘[catlist] in PHP not working correctly’ is closed to new replies.