Skip to content

Instantly share code, notes, and snippets.

@mrkdevelopment
Created April 26, 2017 05:07
Show Gist options
  • Save mrkdevelopment/39cde0ca57b9e512dcef94ef9b3b5304 to your computer and use it in GitHub Desktop.
Save mrkdevelopment/39cde0ca57b9e512dcef94ef9b3b5304 to your computer and use it in GitHub Desktop.
Sample FAQ view file
<?php
$args = array(
'post_type' => 'faq',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'faq_category',
'field' => 'id',
'terms' => explode(',', $attrs['include_categories']),
),
),
);
$query = new WP_Query($args);
while ($query->have_posts()) {
$query->the_post();
echo sprintf("<h6 class='%s'>%s</h6>", $attrs['question_class'], get_the_title());
echo sprintf("<p class='%s'>%s</p>", $attrs['answer_class'], apply_filters('the_content', get_the_content()));
}
wp_reset_query();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment