What I’m trying to accomplish is, when you go to the Healthy Eating page I would like it to display the titles of all blogs associated with that custom taxonomy name, then when I go to Easy Prep page to do the same with those posts.
I was reading about wp_query and the loop and it just made things confusing. Here is what I have so far if someone can help me.
<?php
$args = array(
'post_type' => 'post',
'meta_key' => 'food_type',
'meta_value' => '$post_id',
//'post__in' => '$post->ID',
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
?>
Any help would be
[Moderator Note: No bumping. If it’s that urgent after just 1 hour, please consider hiring someone instead.]
]]>I think I’m fairly close, but I’m still getting empty result arrays. Am I missing something?
Thanks!
$querystr = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wpostmeta.meta_key = 'event_important'
AND wpostmeta.meta_value = 'on'
";
$primary_events = $wpdb->get_results($querystr, OBJECT);
if ($primary_events): ?>
<h1>Events</h1>
<ul>
<?php global $post; ?>
<?php foreach ($primary_events as $post): ?>
<?php setup_postdata($post); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?><span><?php echo get_pretty_date() ?></span></a></li>
<?php endforeach; ?>
<?php else : ?>
<h1 class="center">No Events</h1>
<p class="center">Sorry, there are no events yet.</p>
<?php endif; ?>
]]>I’d appreciate any help.
This is what my code looks like
<ul id=”sidebar” class=”column colblue equalize”>
<?php the_meta(); ?>
<div class=”itementry”>
<?php the_content(__(‘Read more’, ‘hour24band’)); ?>
</div>
<?php endwhile; ?>
here’s an example:
https://picturesfor.me/album-categories/animals
All users are seeing all the thumbnails on the left, and all 4 album listings on the right, whereas the admin user only sees the (correct) 2 thumbnails on the left, and 1 album listing on the right.
here is my query running the thumbnails:
$args = array(
'posts_per_page'=> -1,
'tax_query' => array(
array(
'taxonomy' => 'gallery-categories',
'field' => 'tag_ID',
'terms' => $cur_cat_id
)
)
);
and here is my query for the album posts:
$args = array(
'post_type' => 'albums',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'album-categories',
'field' => 'term_id',
'terms' => get_cat_id( single_cat_title("",false) )
)
)
);
<?php $my_query = new WP_Query('meta_key=featured&meta_value=true&showposts=1');
while ($my_query->have_posts()) :
// Display post information
endwhile; ?>
unfortunately, this is just displaying the latest post, regardless of the custom fields.
Also, later on within my main loop, I’d like to denote stories that were featured, but are now older. Is there and easy way to check a key/value pair from a post within the loop? Thanks.
]]>