Monday, December 12, 2022
HomeWordPress Developmentcustomized publish varieties - Drawback with shortcode

customized publish varieties – Drawback with shortcode


please inform me whats flawed? I’ve publish kind + customized taxonomy, i want show through shortcode with my posts in publish kind through class params:

perform list_faqs_shortcode( $atts ) {

    // Parse your shortcode settings with it is defaults
    $atts = shortcode_atts( array(
        'class' => ''
    ), $atts, 'myprefix_custom_grid' );

    // Extract shortcode atributes
    extract( $atts );
    
    $classes  = explode(',', $atts['category']);
    
    // Outline output var
    $output="";

    // Outline question
    $query_args = array(
        'post_type'      => 'cstore_faq', // Change this to the kind of publish you wish to present
        'posts_per_page' => $posts_per_page,
    );

    // Question by time period if outlined
    if ( $time period ) {

        $query_args['tax_query'] = array(
            array(
                'taxonomy' => 'category_list',
                'subject'    => 'term_id',
                'phrases'    =>  $classes,
                //'phrases'    => $time period,
            ),
        );

    }
    echo $classes;

    // Question posts
    $custom_query = new WP_Query( $query_args );

    // Add content material if we discovered posts through our question
    if ( $custom_query->have_posts() ) {

        // Open div wrapper round loop
        $output .= '<div>';

        // Loop via posts
        whereas ( $custom_query->have_posts() ) {

            // Units up publish information so you should utilize capabilities like get_the_title(), get_permalink(), and so forth
            $custom_query->the_post();

            // That is the output on your entry so what you wish to do for every publish.
            $output .= '<div>!!' . get_the_title() . '!!</div>';

        }

        // Shut div wrapper round loop
        $output .= '</div>';

        // Restore information
        wp_reset_postdata();

    }

    // Return your shortcode output
    return $output;

}
add_shortcode( 'faq_list', 'list_faqs_shortcode' );

and my shortcode:
[faq_list category=”77″]

however not displayed nothing, if i strive show like [faq_list] my posts all displayed appropriately, whats flawed? thanks.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments