Archived topic
Queryselector Text Injected into Post Nav
7 replies · Started by nurban01 on February 7, 2021
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?
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.
Found it, thanks! How did you know where to check?
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.
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.
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. :)
Great explanation, thanks! Hope that this helps someone else too :)
No problem. Glad to be of any help. :D