• Resolved Borgtex

    (@borgtex)


    Hi there.
    I have a widget that it’s configured to appear only on search pages, so I’ve used the [search] condition. Problem is that with the debug mode on, wp shows a notice stating that “is_search was called incorrectly. Conditional query tags do not work before the query is run”

    I traced the problem back to your plugin (the notice disappears when I disable it). While it’s just a notice and it works fine in non debug mode, you may want to correct it in a future version

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Borgtex,

    Thanks for pointing out that warning and for using Widgets Control plugin on your site.

    The warning itself is related to is_search() conditional function which when called will check if the wp_query is set and will return this exact warning if for some reason the wp_query is not there/set. The warning itself is produced only when Widgets Control plugin is activated but it might be the only part of your site that is using the conditional function is_search().

    To work this out I would recommend you to check your search functionality. If you are using a custom-made feature for searching then have a look in the implementation in case there is a sub query for searches or if the main query is not set.
    If on the other hand this is the search functionality provided by your active theme then I would recommend you to temporary switch the active theme to ie one of the default WP themes like Twenty Twenty-one and check again if the warning keeps coming up.

    Please let me know once you have reviewed the aforementioned options.

    Kind regards,
    George

    Plugin Contributor Kento

    (@proaktion)

    I can’t replicate the issue using:

    – WordPress 5.7.2
    – Widgets Control 2.5.0
    – Twenty Twenty-One 1.3

    I’ve placed a Text widget in the Footer sidebar, the widget is using:

    [x] Show only on these pages

    Conditions:
    [search]

    Widgets shows on search pages only.
    No traces produced in the debug.log.

    Closing as this is likely related to particular theme or customizations. Feel free to follow up if you found something out.

    Thread Starter Borgtex

    (@borgtex)

    Hey! sorry for the late response

    After checking further, I think it only happens for the theme I’m using or due to another plugin as gtsiokos suggested, and only when using it to control sidebar visibility; works ok for the widgets.
    Thanks for your help, anyway.

    Hey Borgtex,

    I’m glad you located the source of the issue and according to my description you can even locate the exact place where it is produced. Afterwards you may point this and even quote my recommendation to the respective developer and ask them to review their code.

    Kind regards,
    George

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[search] triggers a called incorrectly notice’ is closed to new replies.