• Resolved krishnashah10990

    (@krishnashah10990)


    get_post_meta not working for fetch single post shortcode.
    my code is
    function product_shortcode_fn( $atts ) {

    $atts = shortcode_atts( array(
    ‘posts_per_page’ => ‘-1’,
    ‘term’ => ”
    ), $atts, ‘myprefix_custom_grid’ );

    extract( $atts );
    $output = ”;
    $query_args = array(
    ‘post_type’ => ‘asp-products’, // Change this to the type of post you want to show
    ‘posts_per_page’ => $posts_per_page,
    );
    if ( $term ) {

    $query_args[‘tax_query’] = array(
    array(
    ‘taxonomy’ => ‘category’,
    ‘field’ => ‘ID’,
    ‘terms’ => $term,
    ),
    );
    }
    $custom_query = new WP_Query( $query_args );
    if ( $custom_query->have_posts() ) {
    $output .= ‘<div>’;
    while ( $custom_query->have_posts() ) {
    $custom_query->the_post();
    $output .= ‘<div class=”col-md-4″ style=”padding-bottom:40px;”>’;
    $output .= get_the_title();
    $output .= get_post_meta(get_the_ID(),’_asp_product_shortcode’,true);
    $output .= ‘</div>’;
    }
    $output .= ‘</div>’;
    wp_reset_postdata();
    }
    return $output;
    }
    add_shortcode( ‘products’, ‘product_shortcode_fn’ );

    please help me.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Contributor Alexander C.

    (@alexanderfoxc)

    Hi.

    There is built-in page that displays all existing products – /products/.

    If you could explain what you’re trying to archive, we could be more helpful.

Viewing 1 replies (of 1 total)

The topic ‘get_post_meta not working’ is closed to new replies.