[Support request] get_template_part( 'content', 'page', get_post_format() );

Home Forums Support [Support request] get_template_part( 'content', 'page', get_post_format() );

Home Forums Support get_template_part( 'content', 'page', get_post_format() );

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #883507
    Marinex

    Can anyone tell me what I’m doing wrong here. I keep getting an empty inside-article div before or after main content when trying to hook to the said places.
    Here is my code;

    <?php
    if (ICL_LANGUAGE_CODE == "sv") {
    	$cat = 'swe';
    } else {
    	$cat = 'casinos';
    }
    
    	 $args = array(
         'category_name' => $cat,
         'posts_per_page' => -1
     );
    
    // The Query
    $the_query = new WP_Query( $args );
    
    // The Loop
    if ( $the_query->have_posts() ) {
    
    	while ( $the_query->have_posts() ) {
    		$the_query->the_post();
    
    		get_template_part( 'content', 'page', get_post_format() );
    	}
    	
    	wp_reset_postdata();
    }
    
    ?>
    #883730
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Instead of this:

    get_template_part( 'content', 'page', get_post_format() );

    Try this:

    get_template_part( 'content', get_post_format() );

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