How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask Jess M. Your Own Question
Jess M.
Jess M., Computer Support Specialist
Category: Software
Satisfied Customers: 654
Experience:  Computer Software Support specialist for more that 10 years
49766785
Type Your Software Question Here...
Jess M. is online now
A new question is answered every 9 seconds

WORDPRESS DEVS! I need help. I'm trying to query posts and a

Customer Question

WORDPRESS DEVS!I need help. I'm trying to query posts and a custom post type. And I can get that. The problem is, there is a custom taxonomy on the custom post type. So when I set up my args, it's trying to put both category and event category as arguments. So it winds up pulling no posts.halp.
Submitted: 3 months ago.
Category: Software
Customer: replied 3 months ago.
This is two of my current code attempts<?php$event_args = array(
'post_type'=>'event',
'suppress_filters'=>false,
'event-category'=>'trezo-mare',
'showpastevents'=>true,//Will be deprecated, but set it to true to play it safe.
);$post_args = array(
'post_type'=>'post',
'posts_per_page'=>5,
'category_name' => 'trezo-mare',
);$custom_query = new WP_Query();$custom_query->posts = array_merge( $event_args->posts, $post_args->posts );//populate post_count count for the loop to work correctly
$custom_query->post_count = $event_args->post_count + $post_args->post_count;?>
<?php echo $postcat; ?>
<?php if ( $custom_query->have_posts() ) : ?>Also have tried this<?php
$args = array(
'post_type'=>'event',
'suppress_filters'=>false,
'event-category'=>'trezo-mare',
'showpastevents'=>true,//Will be deprecated, but set it to true to play it safe.
);$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
endwhile;$args = array(
'post_type'=>'post',
'posts_per_page'=>5,
'category_name' => 'trezo-mare',
);$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
endwhile;wp_reset_postdata();
?>
<?php echo $postcat; ?>
<?php if ( $custom_query->have_posts() ) : ?>
<div class="bv-newspage">
<div class="container">
<div class="row">
<h1>Category Archive: <?php echo single_cat_title( '', false ); ?></h1>
<h2>What's Happening in your Village?</h2>
</div>
</div>
</div><div class="container bv-newspage">
<div class="row">
<div class="two-thirds column">
<div class="row"><?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('full', array('class' => 'scale-with-grid tenant-thmb')); ?></a>
<p class="news-col-byline"><?php the_time('F j, Y'); ?> &bull;
<?php
$taxonomy = 'category';// get the term IDs assigned to post.
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// separator between links
$separator = ', ';if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {$term_ids = implode( ',' , $post_terms );
$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );
$terms = rtrim( trim( str_replace( '<br />', $separator, $terms ) ), $separator );// display post categories
echo $terms;
}
?>
</p>
<h2><?php the_field('tenant_property_name'); ?><br/><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<a class="button" href="<?php the_permalink(); ?>">Read More</a>
<hr/><?php endwhile; ?>
</div>
</div><?php else: ?><h2>No posts to display in <?php echo single_cat_title( '', false ); ?></h2></div><?php endif; ?>
Expert:  Josh replied 3 months ago.

Hi! My name is ***** ***** I will be assisting you. Let's get started!

Expert:  Josh replied 3 months ago.

I apologize that you had to wait a long time for a response.

Please let us know if you still need help with your question and if I am not able to help you, I can send it to other experts that can help you.