[Support request] Comments showing in the wrong place on blog posts

Home Forums Support [Support request] Comments showing in the wrong place on blog posts

Home Forums Support Comments showing in the wrong place on blog posts

  • This topic has 8 replies, 3 voices, and was last updated 7 years ago by Tom.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #310201
    wekhter

    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.

    #310213
    Leo
    Staff
    Customer Support

    Hi there,

    Can you explain a little more? I see the comments below the posts.

    Let me know πŸ™‚

    #310234
    wekhter

    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.

    #310254
    Leo
    Staff
    Customer Support

    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

    #310273
    Tom
    Lead Developer
    Lead Developer

    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.

    #310282
    wekhter

    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 ?

    #310334
    Tom
    Lead Developer
    Lead Developer

    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
    #310706
    wekhter

    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?

    #310772
    Tom
    Lead Developer
    Lead Developer

    Not currently, but I’ll look into that πŸ™‚

    Glad everything else is working! πŸ™‚

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