Below content widget appears above content

Community Forums Forums General Discussion Below content widget appears above content

This topic is: not resolved

This topic contains 13 replies, has 3 voices, and was last updated by  songdogtech 7 months, 3 weeks ago.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #80083

    songdogtech
    Participant
    Post count: 67

    I’m trying to add a below content widget to a Custom Post Type template. but the widget appears above the content. Nothing I do makes this change.

    I’m using a CPT and also showing custom field data with a wp_query.

    This is my page template called single-hhdata.php

    
    function hhdata_loop() {
    	global $post;
    $args = array(
    		'post_type' => 'hh-data',
    		'posts_per_page' => 1,
    		'post_status' => 'publish',
    	);
     
    $wp_query = new WP_Query( $args );
    
    if ( have_posts() ) : while ( have_posts() ) : the_post(); 
    
    //echoing a lot of custom field data
    
    endwhile; endif;
     
    wp_reset_query();
    }
    
    add_action( 'genesis_loop', 'hhdata_loop' );
     
    genesis();
    

    This is what I’m using in functions.php, and it inits the widget in admin and shows the widget content on a single CPT page, but the contents of the widget appear above the content, not below:

    /** Register Below HH Post Widget area */
    
    genesis_register_sidebar( array(
    	'id'          => 'below-hh-area',
    	'name'        => __( 'Below HH Area Widget', '$text_domain' ),
    	'description' => __( 'This is the Below HH Area section', '$text_domain' ),
    ) );
     
    add_action( 'genesis_after_post_content', 'below_hh_area_widget' ); 
    
    function below_hh-area_widget() {
    
    if ( is_singular( 'hh-data' ) && is_active_sidebar('below-hh-area') ) {
     
        genesis_widget_area( 'below-hh-area', array(
    		'before' => '<div class="below-hh-area widget-area">',
    		'after'  => '</div>',
        ) );
    	}  
    }
    
    

    I use this for a widget after posts, but removing this doesn’t make the after CPT widget placement, and this widget doesn’t show on the CPT template above.

    
    add_action( 'genesis_after_post_content', 'focus_after_post' );
    function focus_after_post() {
    	if ( ! is_singular( 'post' ) )
    	return;
    	genesis_widget_area( 'after-post', array(
    		'before' => '<div class="after-post widget-area">',
       ) );
    }
    

    Is the issue the CPT or the wp_query loop showing the custom field data? Or is there a conflict between the two after post calls?


    I’m on WordPress Answers (Stack Exchange) and WordPress.org Support Forums and check my consulting and portfolio site at markkratledge.com

    • This topic was modified 8 months ago by  songdogtech.
    • This topic was modified 8 months ago by  songdogtech.
    • This topic was modified 8 months ago by  songdogtech.
    • This topic was modified 8 months ago by  songdogtech.
    #80104

    braddalton
    Participant
    Post count: 9210

    Firstly, you need to use the conditional tag for a custom post type.

    This is wrong [php]if ( is_singular( ‘hh-data’ )[/php]

    This works
    [php]if( ‘hh-data’ == get_post_type()[/php]
    Try adding the 3rd parameter for positioning

    Example
    [php]
    add_action( ‘genesis_after_post_content’, ‘below_hh_area_widget’, 11 );
    [/php]
    Secondly, are you running XHTML or HTML 5?

    Link to your site please.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #80212

    songdogtech
    Participant
    Post count: 67

    Thanks, I did have the conditional wrong, and I didn’t know there was a parameter for positioning, but no luck with either of those changes.

    This is Focus XHTML, but once I get everything done, I’m converting it to Focus Pro HTML5 re: http://wpsites.net/wordpress-themes/how-to-convert-your-studiopress-child-theme-from-xhtml-to-html-5/

    And this is on my dev server, so it’s not accessible.

    The full focus_after_post function is below, which I forgot to include earlier; is there a conflict here?

    add_action( 'genesis_after_post_content', 'focus_after_post' );
    function focus_after_post() {
    	if ( ! is_singular( 'post' ) )
    	return;
    	
    genesis_widget_area( 'after-post', array(
    		'before' => '<div class="after-post widget-area">',
       ) );
    }
    
    genesis_register_sidebar( array(
    	'id'				=> 'after-post',
    	'name'			=> __( 'After Single Post Widget', '$text_domain' ),
    	'description'	=> __( 'This is the After Post Widget section.', '$text_domain' ),
    ) );
    

    And this is the source, which shows the widget is dumping the text below entry-content:

    <div id="inner">
    <div class="wrap">
    <div id="content-sidebar-wrap">
    <div id="content" class="hfeed">
    <div class="post-9999 type-hh-data  hentry entry">
    <div class="entry-content"></div>
    <div class="below-hhdata widget-area">
    <div id="text-12" class="widget widget_text">
    <div class="widget-wrap"><div class="textwidget">
    Below HHdata text in widget
    </div>
    </div>
    </div>
    

    I’m on WordPress Answers (Stack Exchange) and WordPress.org Support Forums and check my consulting and portfolio site at markkratledge.com

    • This reply was modified 8 months ago by  songdogtech.
    • This reply was modified 8 months ago by  songdogtech.
    #80413

    braddalton
    Participant
    Post count: 9210

    The code for the widget is wrong.

    Change this:
    [php]
    genesis_widget_area( ‘after-post’, array(
    ‘before’ => ‘<div class="after-post widget-area">’,
    ) );
    }
    [/php]

    To this:

    [php]
    genesis_widget_area( ‘after-post’, array(
    ‘before’ => ‘<div class="after-post widget-area">’,
    ‘after’ => ‘</div>’,
    ) );
    }
    [/php]

    I would also include the 3rd parameter as you’re using the same hook twice;
    [php]
    add_action( ‘genesis_after_post_content’, ‘focus_after_post’, 15 );
    [/php]


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #80465

    songdogtech
    Participant
    Post count: 67

    Thanks, but still no luck with this:

    
    /** Register After Single Post Widget Area */
    
    genesis_register_sidebar( array(
    	'id'				=> 'after-post',
    	'name'			=> __( 'After Single Post Widget', '$text_domain' ),
    	'description'	=> __( 'This is the After Post Widget section.', '$text_domain' ),
    ) );
    
    add_action( 'genesis_after_post_content', 'focus_after_post', 15 );
    
    function focus_after_post() {
    	if ( ! is_singular( 'post' ) )
    	return;
    	
    genesis_widget_area( 'after-post', array(
    		'before' => '<div class="after-post widget-area">',
    		'after'  => '</div>',
       ) );
    }
    
    /** Register Below HHData Post Widget Area */
    
    genesis_register_sidebar( array(
    	'id'          => 'below-hhdata',
    	'name'        => __( 'Below HHdata Widget', '$text_domain' ),
    	'description' => __( 'This is the Below HHdata section', '$text_domain' ),
    ) );
     
    add_action( 'genesis_after_post_content', 'below_hhdata_widget', 11 ); 
    
    function below_hhdata_widget() {
    
    if( 'horoscope' == get_post_type() ) {
     
        genesis_widget_area( 'below-hhdata', array(
    		'before' => '<div class="below-hhdata widget-area">',
    		'after'  => '</div>',
        ) );
     
    	}  
    }
    

    Page template called single-hhdata.php

    
    function hhdata_loop() {
    	global $post;
    $args = array(
    		'post_type' => 'hh-data',
    		'posts_per_page' => 1,
    		'post_status' => 'publish',
    	);
     
    $wp_query = new WP_Query( $args );
    
    if ( have_posts() ) : while ( have_posts() ) : the_post(); 
    
    //echoing a lot of custom field data
    
    endwhile; endif;
     
    wp_reset_query();
    }
    
    add_action( 'genesis_loop', 'hhdata_loop' );
     
    genesis();
    

    I’m on WordPress Answers (Stack Exchange) and WordPress.org Support Forums and check my consulting and portfolio site at markkratledge.com

    #80485

    genwrock
    Member
    Post count: 499

    are you using HTML5 markup? in your functions.php file have this code ‘add_theme_support( ‘html5′ );’ ?


    Working as a freelancer & helping the people on forum | Chinmoy @ PWD | Please Follow Me on Twitter If I’ve helped.

    #80505

    songdogtech
    Participant
    Post count: 67

    This is Focus XHTML.


    I’m on WordPress Answers (Stack Exchange) and WordPress.org Support Forums and check my consulting and portfolio site at markkratledge.com

    #80566

    genwrock
    Member
    Post count: 499

    Then this can be work

    add_action( 'genesis_after_post_content', ''below_hhdata_widget'' );
    function below_hhdata_widget(){
      if(( 'hh-data' == get_post_type() )  && is_single() ) {
     
        genesis_widget_area( 'below-hhdata', array(
    		'before' => '<div class="below-hhdata widget-area">',
    		'after'  => '</div>',
        ) );
     
      }  
    }

    Working as a freelancer & helping the people on forum | Chinmoy @ PWD | Please Follow Me on Twitter If I’ve helped.

    #80571

    braddalton
    Participant
    Post count: 9210

    I have tested this code and it works perfectly:

    Change portfolio to the name of your CPT.

    This code works on HTML 5 themes only.

    I suggest you convert to HTML 5. http://cobaltapps.com/genesis-xhtml-to-html5-css-converter/

    I didn’t test the code on a XHTML theme because of the time involved to setup a CPT on a XHTML site.

    For sites running XHTML, change [php]genesis_entry_footer[/php] to [php]genesis_after_post_content[/php]


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    • This reply was modified 8 months ago by  braddalton.
    • This reply was modified 8 months ago by  braddalton.
    #80575

    genwrock
    Member
    Post count: 499

    @braddalton

    Yes. if he use the HTML5 markup then your code will work on his child theme. But he is using the XHTML and XHTML is not supporting the ‘genesis_enrty_footer’ hook. It is for HTML5 only.


    Working as a freelancer & helping the people on forum | Chinmoy @ PWD | Please Follow Me on Twitter If I’ve helped.

    #80583

    braddalton
    Participant
    Post count: 9210

    @gemrock Your code is wrong. http://www.studiopress.com/forums/topic/below-content-widget-appears-above-content/#post-80566

    I clearly stated that the code works for HTML 5

    Its a 2 minute job to update to HTML 5.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #81405

    songdogtech
    Participant
    Post count: 67

    @braddalton, thanks, but I’m still beating my head against the keyboard with this. I converted to HTML5.

    All the other post and page before_entry and entry_footer widgets work, and deleting them doesn’t help with this one.

    I added a before_entry hhdata widget, but both of these render above the content. Tried changing the 3rd parameter in many different ways and with the other widgets with no luck.

    
    /** Register Above hhdata Widget Area */
    
    genesis_register_sidebar( array(
    	'id'          => 'above-hhdata',
    	'name'        => __( 'Above hhdata Widget', '$text_domain' ),
    	'description' => __( 'This is the Above hhdata section', '$text_domain' ),
    ) );
     
    add_action( 'genesis_before_entry', 'above_hhdata_widget'); 
    
    function above_hhdata_widget() {
    
    if( 'hhdata' == get_post_type() && is_single() ) {
     
        genesis_widget_area( 'above-hhdata', array(
    		'before' => '<div class="above-hhdata widget-area">',
    		'after'  => '</div>',
        ) );
     
    	}  
    }
    
    /** Register Below hhdata Widget Area */
    
    genesis_register_sidebar( array(
    	'id'          => 'below-hhdata',
    	'name'        => __( 'Below hhdata Widget', '$text_domain' ),
    	'description' => __( 'This is the Below hhdata section', '$text_domain' ),
    ) );
     
    add_action( 'genesis_entry_footer', 'below_hhdata_widget', 11 ); 
    
    function below_hhdata_widget() {
    
    if( 'hhdata' == get_post_type() && is_single() ) {
     
        genesis_widget_area( 'below-hhdata', array(
    		'before' => '<div class="below-hhdata widget-area">',
    		'after'  => '</div>',
        ) );
     
    	}  
    }
    

    The page template:

    
    function hhdata_loop() {
    global $post;
    
    $args = array(
    		'post_type' => 'hhdata',
    		'posts_per_page' => 1,
    		'post_status' => 'publish',
    	);
     
    $wp_query = new WP_Query( $args );
    
    if ( have_posts() ) : while ( have_posts() ) : the_post(); 
    
    //echoing custom field data
    
    endwhile;
    
    endif;
     
    	wp_reset_query();
    }
    
    add_action( 'genesis_loop', 'hhdata_loop' );
     
    genesis();
    

    I’m on WordPress Answers (Stack Exchange) and WordPress.org Support Forums and check my consulting and portfolio site at markkratledge.com

    #81434

    braddalton
    Participant
    Post count: 9210

    Can you link to the page template please.


    Specializing In StudioPress Child Theme Customization.
    500+ StudioPress Tutorials

    #81443

    songdogtech
    Participant
    Post count: 67

    Thanks for your help; this is still on a demo server, but I emailed the demo site login and password.


    I’m on WordPress Answers (Stack Exchange) and WordPress.org Support Forums and check my consulting and portfolio site at markkratledge.com

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.