Archived topic
Comments showing in the wrong place on blog posts
8 replies · Started by wekhter on April 25, 2017
Just switched to GeneratePress on a live site and somehow the comments are showing up in the wrong place on blog posts. Eek!
Here's an example page:
http://www.gozen.com/9-things-every-parent-with-an-anxious-child-should-try/
I've been preparing for this theme switch for a while on a local site and never ran into anything like this.
Hi there,
Can you explain a little more? I see the comments below the posts.
Let me know :)
Hi Leo, I set the comment area to clear:both so at least it wouldn't look as insane (as it's a live site), but you should be able to see that on that page the comments are preventing the sidebar from being in the proper place.
If you look in the source code, you'll see that, quite literally, the comment area is not nested where it should be. I've managed to narrow this down to probably being an issue with this plugin: https://wordpress.org/plugins/add-widget-after-content/
... Which is weird, because I've been testing with that plugin in mind on a local site for weeks now! It looks like on any post where that widget is enabled, the whole page layout gets screwy.
The reason I have that plugin installed is to let me have content on most posts, but with the ability to disable it sometimes--just like how the GP "Disable Elements" works. Is there a way I can hook into the Disable Elements feature and add in my own custom widget (that can be disabled on a per-post basis) to bypass whatever this plugin is doing?
Also, is there a way to programmatically disable certain elements by default? For instance, automatically disabling navigation on certain page templates.
I think this plugin might help: https://en-ca.wordpress.org/plugins/display-widgets/
To remove navigation, easiest way is to use CSS, or you can use a filter with conditional statement:
https://generatepress.com/forums/topic/remove-navigation-from-certain-pages/#post-261130
https://codex.wordpress.org/Conditional_Tags
You could basically use the register_sidebar() function register a new widget area, then add it below the content using Hooks.
Then the plugin Leo suggested will allow you to show/remove the widgets in that newly created area.
Thanks, I can get something worked out from that.
Question: I want to change the display of the secondary navigation, not the primary navigation. I see from the docs the primary navigation filter is generate_navigation_location is the secondary one generate_secondary_navigation_location ?
That filter doesn't exist currently.
However, you could this:
add_filter( 'option_generate_secondary_nav_settings','tu_secondary_nav_location' );
function tu_secondary_nav_location( $options ) {
$options[ 'secondary_nav_position_setting' ] = 'secondary-nav-below-header';
return $options;
}
These are the available options:
secondary-nav-below-header
secondary-nav-above-header
secondary-nav-float-right
secondary-nav-left-sidebar
secondary-nav-right-sidebar
First of all: turns out the comments thing wasn't any sort of plugin issue, it was 100% my fault. Whoops! But with your help I was able to just set up a sidebar instead of having another plugin installed, so all's well that ends well.
Secondly: Thanks! That code is exactly what I was looking for. Here's what I ended up with, in case it can help someone else:
add_filter( 'option_generate_secondary_nav_settings','tu_secondary_nav_location' );
function tu_secondary_nav_location( $options ) {
if ( is_page( 'page-slug' ) || is_singular( array ( 'cpt1', 'cpt2' ) ) || is_post_type_archive( 'cpt1' ) ) {
$options[ 'secondary_nav_position_setting' ] = 'secondary-nav-below-header';
return $options;
}
else {
$options[ 'secondary_nav_position_setting' ] = '';
return $options;
}
}
This way I have the secondary nav show up for certain post types (and a paage) that need it, but doesn't show up anywhere else. :)
BTW--I only just realized that tu_ is Tom Usborne. Seems so obvious now!
EDIT: Just noticed that secondary nav inline CSS still loads on pages w/o secondary nav--not really a huge deal but is there a way to disable that as well?
Not currently, but I'll look into that :)
Glad everything else is working! :)