- This topic has 8 replies, 3 voices, and was last updated 7 years ago by Tom.
-
AuthorPosts
-
April 25, 2017 at 11:40 am #310201wekhter
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.
April 25, 2017 at 12:22 pm #310213LeoStaffCustomer SupportHi there,
Can you explain a little more? I see the comments below the posts.
Let me know π
April 25, 2017 at 1:21 pm #310234wekhterHi 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.
April 25, 2017 at 2:12 pm #310254LeoStaffCustomer SupportI 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_TagsApril 25, 2017 at 2:35 pm #310273TomLead DeveloperLead DeveloperYou 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.
April 25, 2017 at 2:54 pm #310282wekhterThanks, 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 onegenerate_secondary_navigation_location
?April 25, 2017 at 7:31 pm #310334TomLead DeveloperLead DeveloperThat 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
April 26, 2017 at 2:26 pm #310706wekhterFirst 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?
April 26, 2017 at 4:32 pm #310772TomLead DeveloperLead DeveloperNot currently, but I’ll look into that π
Glad everything else is working! π
-
AuthorPosts
- You must be logged in to reply to this topic.