I would like to query information in my sidebar text widget. I added the function. The php query working. (see the code below)
I have single posts with wine tastings. I would like to show in right sidebar which cellar producted it. I added the same custom field key cellar_slug
and value somloi-apatsagi-cellar
each post. Code below can show the cellar.
But how can I using on all posts? Every post have different meta value. Is there any solution using current post meta value instead of a fix value?
<?php
$cellars = new WP_Query(array(
'post_type' => 'post',
'numberposts' => -1,
'posts_per_page' => '1',
'meta_query' => array(
array(
'key' => 'cellar_slug',
'value' => 'somloi-apatsagi-cellar',
)),
'orderby' => 'menu_order',
'order' => 'ASC'
));
if ($cellars->have_posts()) : ?>
<u1>
<?php
while ($cellars->have_posts()) :
$cellars->the_post(); ?>
<li><h3><a href="<?php the_permalink(); ?>">
<?php the_title(); ?></a></h3><?php the_post_thumbnail('widget-text-post-thumbnail'); ?><?php the_excerpt(); ?>
</li>
<?php endwhile; ?>
</u1>
<?php endif; ?>