Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ahmedmusawir/1eff3fd71d7ab0482a4f6d49785db364 to your computer and use it in GitHub Desktop.
Save ahmedmusawir/1eff3fd71d7ab0482a4f6d49785db364 to your computer and use it in GitHub Desktop.
WP - WP_QUERY LOOP - W/ CUSTOM POST TYPE & CUSTOM TAXONOMY
<?php
$counter = 0;
$item_count = 0;
$args = array(
'post_type' => 'portfolio',
'tax_query' => array(
array(
'taxonomy' => 'portfolio-item',
'field' => 'slug',
'terms' => 'featured'
)
),
'posts_per_page' => 4
);
$front_page_post_items = new WP_Query($args);
if ($front_page_post_items->have_posts()): /* Start the Loop */
while ($front_page_post_items->have_posts()):
$front_page_post_items->the_post();
?>
... ... ...
... ... ...
<?php
endwhile;
else:
get_template_part('template-parts/content', 'none');
endif;
wp_reset_postdata();
?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment