[Resolved] Queryselector Text Injected into Post Nav

Home Forums Support [Resolved] Queryselector Text Injected into Post Nav

Home Forums Support Queryselector Text Injected into Post Nav

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1649718
    nurban01

    Hi,

    Not 100% this is a GP issue, but I think it is related.

    For some reason, right after:
    <nav id="site-navigation" class=" main-navigation grid-container grid-parent sub-menu-right" I have the following #text now displaying in my site header (but only within Posts).

    document.querySelector("h2");

    I searched through my full WP install with the String Locator plugin and also tried in another browser. Any ideas?

    #1649741
    Elvin
    Staff
    Customer Support

    Hi there,

    You seem to have something that hooked this string to generate_inside_navigation.

    Can you check for any Hook Element that has this string in it?

    If you have Code Snippets plugin and/or functions.php snippets, you can also check for any code that has something like this:

    add_action('generate_inside_navigation',...

    Let us know.

    #1650630
    nurban01

    Found it, thanks! How did you know where to check?

    #1651251
    Elvin
    Staff
    Customer Support

    Found it, thanks! How did you know where to check?

    It’s from familiarity with the theme’s hooks, experience + chrome devtools.

    Just by inspecting the page’s code using Google Chrome’s devtools, when something shows up on a certain part of the site, we already have an idea of how it’s placed there.

    We actually have some sort of a hook “map”. See our Hook Visual Guide: https://docs.generatepress.com/article/hooks-visual-guide/

    No problem. Glad you got it sorted.

    #1652202
    nurban01

    we already have an idea of how it’s placed there.

    I’m familiar with Chrome’s Devtools. I’m especially curious how you knew that it was inserted from a hook rather than a core theme file, plugin, PHP snippet, etc. I didn’t see any references to hooks around the text.

    #1652350
    Elvin
    Staff
    Customer Support

    I’m familiar with Chrome’s Devtools. I’m especially curious how you knew that it was inserted from a hook rather than a core theme file, plugin, PHP snippet, etc. I didn’t see any references to hooks around the text.

    Our reference is where the things appear within the HTML structure.

    Since we’re familiar with what the default elements are used by the theme, we usually know what elements are either filtered or hooked in.

    Say for example, if something appears before the <header id="masthead"> element. Looking at the Hook visual guide, we already have an idea that it’s either hooked to generate_before_header or wp_body_open even when there’s no reference or clue html tags like <!--comments--> because the fact that it appears before <header id="masthead"> is the clue. 🙂

    So to put simply, if something isn’t a “default” element of the theme, it’s most likely hooked in, filtered or there’s a child theme template involved. 🙂

    #1652459
    nurban01

    Great explanation, thanks! Hope that this helps someone else too 🙂

    #1652474
    Elvin
    Staff
    Customer Support

    No problem. Glad to be of any help. 😀

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.