Site logo

Archived topic

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

1 reply · Started by Marinex on April 29, 2019

Viewing posts 1–2 of 2

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();
}

?>

Hi there,

Instead of this:

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

Try this:

get_template_part( 'content', get_post_format() );

This archived topic is closed to new replies.