Have wordpress based site, where:
MainCategory
MainCategory2
MainCategory3
As you can see, all subacegories in main categories are the same. With same name (not slug), and there are custom fields with same field values.
I need to display posts that is in MainCategory2
AND subcategory has custom field with value custom2
. Is this possible?
PS I use ACF plugin for custom fields.
I'm not sure if this is the best solution, but it will hopefully solve your problem.
The code would look like this:
<?php query_posts( 'showposts=20&cat=2&order=ASC' ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php if( get_field('custom-field') == 'custom2' ): ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
<?php else : ?>
<?php endif; ?>
<?php endwhile; endif; ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.