I’ve created this hook in the elements section after_main_content with priority 22.
The aim is to use a page as a hub and display only posts from a specific category.
Not sure what is wrong here but none of my posts a specific category are displaying.
Below is the code I put in the element hook.
<div class="generate-columns-container">
<?php
$args = array(
'post_type' => 'post',
'cat'=>39,
'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'ASC'
);
$query = new WP_Query( $args );
if($query->have_posts()) : while($query->have_posts()) : $query->the_post();
if (has_post_thumbnail()) { ?>
<article <?php $postid = get_the_ID(); ?> class="hub-grid tablet-grid-50 mobile-grid-100 grid-parent grid-33 no-featured-image-padding" itemtype="https://schema.org/CreativeWork" itemscope="">
<div class="inside-article design-article">
<header class="entry-header">
<a href="<?php get_permalink( $postid ); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(); ?></a>
</header>
<div class="entry-summary" itemprop="text">
<h2 class="entry-title" itemprop="headline"><a href="<?php the_permalink($postid); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<div>
</div>
</article> <?php
}
endwhile;endif;?>
</div>