skip to Main Content

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

2

Answers


  1. Chosen as BEST ANSWER

    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');
    

  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search