WordPress › Blog Tool  Publishing Platform  and CMS

Show Posts from Custom Taxonomies Using WordPress Shortcode

WordPress made it easy to create a shortcode and use it inside any post/pages anywhere you want on your website, sometime you need to create custom taxonomy for your site and need to retrieve all posts assigned to it.

To create a shortcode

ob_get_clean — Get current buffer contents and delete current output buffer

from looking at the code above we see that we need to create a page called loop-categorymedia.php


I create this shortcode originally for pulling the posts from this plugin Enhanced Media Library , this plugin use to organize the Media library for WordPress, gives you abilities to add Categories and Organize them.

Inside loop-categorymedia.php file

first we get the shortcode and extract it to get the value id for the category we want:

Now we have $termId which equal to our Category Id inside the Media.