• Resolved toolsavvy

    (@toolsavvy)


    I want to add a WOOCS dropdown to my shop’s search results page, not in widget. Initially I had put the WOOCS shortcode in archive-product.php file…

    echo do_shortcode('[woocs show_flags="1" width="300px" flag_position="left" txt_type="code"]');

    But the theme author told me not to do that and to use add_action function in my child theme’s functions.php file instead. He said to use the following code…

    add_action( 'woocommerce_archive_description', 'action_function_name_7899' );
    function action_function_name_7899(){
        do_shortcode('[woocs show_flags="1" width="300px" flag_position="left" txt_type="code"]');
    }

    But that is not working. I am guessing because…

    action_function_name_7899
    and
    function action_function_name_7899()

    …need to be changed to something else.

    Do you know what that something else is?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello

    Try this code

    add_action( 'woocommerce_archive_description', 'action_function_name_7899' );
    function action_function_name_7899(){
        echo do_shortcode('[woocs show_flags="1" width="300px" flag_position="left" txt_type="code"]');
    }
    Thread Starter toolsavvy

    (@toolsavvy)

    Yes, that was the problem. The “echo” was missing and I did not catch that myself. lol

    Thank you so much.

    Hello

    Welcome;)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add to search page via add_action in functions file?’ is closed to new replies.