Home > Back-end >  Show actual thumbnail of the category page with the ID with wordpress
Show actual thumbnail of the category page with the ID with wordpress

Time:10-18

i need some help on wordpress

I have to show the thumbnail of my category product of my current category page

So for that i use :

[product_categories ids='116'] It's display the cat id 116.

But i'm blocked for the next thing. Get the id of the current page instead of writing it manually.

Thanks for the help

CodePudding user response:

You can get the category ID using the below code

$category = get_queried_object();
$cat_id = $category->term_id;
echo $cat_id;

You can use this ID and do the rest of things.

CodePudding user response:

So with the help of full stop i write this to solve my problem

function wpc_elementor_shortcode2( $atts ) {
    $category = get_queried_object();
    $cat_id = $category->term_id;
    echo do_shortcode('[product_categories ids="$cat_id"][/product_categories]');
}
add_shortcode( 'my_elementor_php_output2', 'wpc_elementor_shortcode2');
  • Related