trying to display custom post type with custom taxonomy value by shortcode can’t works

Question

function register_shortcodes() {
add_shortcode( ‘characteristics’, ‘shortcode_sj_charcs’ );
}
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”>

0
Logu 4 weeks 2022-11-03T23:51:11-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse