WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] is_search() not working (2 posts)

  1. RRikesh
    Member
    Posted 1 year ago #

    Hello Chouby

    I have a problem on my search results page. The function is_search() isn't being triggered. I tried other is_xxx() functions and saw that it is is_tax() that is being triggered with the language name as term - tested with the following code:

    $term = $wp_query->get_queried_object();
    $title .= $term->name;

    The url structure of the results page is:
    [domain-name]/[LANG]/?s=[query]

    From the url structure, I guess it is because the language is being considered as a taxonomy that is_tax() is being triggered.

    For the time being I'm using this hack when using is_tax() to detect the results page:

    if( 'English' == $term->name || 'Fran├žais' == $term->name ){
          if( function_exists( 'pll_register_string' ) ){
            $title .= pll__( 'Results Page' );
          }
        }

    Is there any direct way to detect the search result using is_search() or the method mentioned above is the good way to proceed?

    Polylang Version: 0.9.3

    http://wordpress.org/extend/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    It's curious that I don't reproduce this problem with is_search()
    However I tried to suppress the is_tax flag on search pages (issue that I reproduced easily) in the current development version (0.9.3.2).
    http://downloads.wordpress.org/plugin/polylang.zip
    Maybe this will solve your issue with is_search

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags