我没有从主题选项中的数组中查询自定义帖子类型分类法。
我的完整代码如下所示,如果能得到一些反馈以使其正常工作,我将不胜感激,因为我无法使其正常工作。
// Pull all the custom taxonomies into an array
// options.php
$options_taxonomies = array();
$taxonomies_terms_obj = get_terms(\'portfolio_category\');
foreach ($taxonomies_terms_obj as $taxonomy) {
$options_taxonomies[$taxonomy->term_id] = $taxonomy->name;
}
// Select a Featured Homepage Category
$options[] = array(
\'name\' => __(\'Featured Homepage Category\', \'options_framework_theme\'),
\'desc\' => __(\'Choose a category to feature on your homepage.\', \'options_framework_theme\'),
\'id\' => \'homepage_feature\',
\'type\' => \'select\',
\'options\' => $options_taxonomies);
}
// WP_Query and Loop
// front-page.php
<?php
$num_cols = 3; // set the number of columns here
if ( function_exists( \'of_get_option\' ) ) :
$args = array(
\'posts_per_page\' => 3,
\'tax_query\' => array(
array(
\'taxonomy\' => \'portfolio\',
\'field\' => \'id\',
\'terms\' => of_get_option( \'homepage_feature\' )
)
)
);
$my_qry = new WP_Query($args);
if (have_posts()) :
for ( $i=1 ; $i <= $num_cols; $i++ ) :
echo \'<div id="col-\'.$i.\'" class="four columns entry-thumb">\';
$counter = $num_cols + 1 - $i;
while (have_posts()) : the_post();
if( $counter%$num_cols == 0 ) : ?>
<!-- core post area; title, content, thumbnails, postmeta, etc -->
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(\'thumbnail-home\', array(\'class\' => \'image-fade\')); ?></a>
<p class="entry-title-home"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
<?php endif;
$counter++;
endwhile;
rewind_posts();
echo \'</div>\'; //closes the column div
endfor;
else:
echo \'<div class="four columns">Please create a post.</div>\';
endif;
endif; rewind_posts(); wp_reset_query();
?>