This tutorial Provides the steps to display related post from the current category on singular post excluding the current post supports custom post types and taxonomy.
Prerequisite:
It is assumed that You have the following points done. We have the following:
Custom Post Type → book
Custom Taxonomy → book_type
STEP 1
The first step is to support shortcodes within the loop query. Add this in wp-config.php
define('PODS_SHORTCODE_ALLOW_SUB_SHORTCODES',true);
STEP 2
It is time to allow shortcodes in Template. Add this in functions.php
/** * Allow Pods Templates to use shortcodes * * NOTE: Will only work if the constant PODS_SHORTCODE_ALLOW_SUB_SHORTCODES is defined and set to */ add_filter( 'pods_shortcode', function( $tags ) { $tags[ 'shortcodes' ] = true; return $tags; });
STEP 3
Create a pod template name > related < and paste this
<div class="related"> <div class="related-wrap"> <h3><a href="{@permalink}" class="my-title">{@post_title}</a></h3> <span class="my-excerpts">{@post_excerpt}</span> </div> </div>
Customize this template as per your needs.
STEP 4
Create a new Pod Template name >php< and paste
[[pods template="related" name="book" where="(regio.term_id = '{@regio.term_id}') AND (ID != '{@ID}')" limit="3"]]
STEP 5
Create a widget area after entry on the singular post. and Drag Pod single item to this section.
a) Select Pod to custom post type of yours.
b) Tick > Use current post (singular) or term (term archive)
c) Select Template php(we have created above)
Save it.
Pods > Settings and clear Pod cache.