Trying to display custom post type with custom taxonomy value by shortcode may not work

function register_shortcode() { add_shortcode(‘attributes’, ‘shortcode_sj_church’); } add_action(‘init’, ‘register_shortcodes’);

function shortcode_sj_charcs($atts) { ob_start(); global $wp_query, $post;

$atts = shortcode_atts( array(
    'catgy' => ''
), $atts, 'characteristics' );

$loop = new WP_Query( array(
    'posts_per_page'    => 200,
    'post_type'         => 'characteristics',
    'orderby'           => 'menu_order title',
    'order'             => 'ASC',
    'tax_query'         => array( array(
        'taxonomy'  => 'characteristics_category',
        'field'     => 'slug',
        'terms'     => array( sanitize_title( $atts['catgy'] ) )
    ) )
) );

if( ! $loop->have_posts() ) {
    return false;
}

,

have_posts()) { $loop->the_post(); ?> “class=”text-white”>

Leave a Comment