Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author HelgaTheViking

    (@helgatheviking)

    See the FAQ for an example. In the case of search you need to find the appropriate theme template to modify… in the case of TwentyFifteen for example, the template would be content-search.php. This can also commonly be content.php, but every theme is different and I can’t support every theme.

    Thread Starter another-webmaster

    (@another-webmaster)

    Probably is my lack of english debet on the (logical/correct) answer on the question as given.

    What I want/meant is NOT how to put the subtitle on the search page but how to search through subtitles also.
    When using Relevanssi plugin it seems not standard to do also a search through the subtitles.
    I added some code in the Relevanssi plugin (yes it actualy should not be done) and now it does a search also for the subtitle.

    Thank you for answering so fast, and sorry for responding this late.

    Plugin Author HelgaTheViking

    (@helgatheviking)

    Thank you for clarifying. I am not familiar with that particular plugin and couldn’t provide support for it. I would advise trying to find a way to avoid modifying plugin code so you are prevented from upgrading in the future. That plugin‘s documentation may explain how to add meta keys to the search. The subtitle is saved as post meta under the key kia_subtitle

    Hello,
    With your help was successful in getting the subtitle loop into the cart. Thanks again!

    My final task is to get subtitle to also appear under product name for
    Search results.

    I recently made some progress, but now stuck and need some help.

    When the first result in the search is a product that has the subtitle, the subtitle also appears under every menu item in the header.

    How do I prevent the subtitle from appearing in the menu header?

    This is the code I’m using.

    function kia_subtitle_for_woocommerce_products_title( $title, $product ){

    if ( is_search() && get_post_type() === ‘product’ ) {
    GLOBAL $product;
    if( function_exists( ‘get_the_subtitle’ ) && $subtitle = get_the_subtitle( $product->id ) ){
    $title .= ‘<div class=”searchauthor”>’ . $subtitle . ‘</div>’;
    }
    }

    return $title;
    }
    add_filter( ‘the_title’, ‘kia_subtitle_for_woocommerce_products_title’, 10, 2 );

    Hope you can help. Many thanks in advance!

    Plugin Author HelgaTheViking

    (@helgatheviking)

    I thought about filtering the_title to automatically add the subtitle directly from the plugin. Ultimately I didn’t because it would probably result in wonky HTML markup (such as an <h2> nested inside an <h1>) AND as you have discovered adds the subtitle literally everywhere. So with that I would advise finding a more theme-specific approach. A template or a theme hook to attach to.

    But if you want to keep filtering the_title the conditional that might help you is is_main_query(). You can read about it in the codex:

    https://codex.wordpress.org/Function_Reference/is_main_query

    Thanks for the quick reply! Will research your ideas.. fingers crossed 🙂
    Have a great weekend.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘include subtitle also in search?’ is closed to new replies.