<?php $pid = get_post(get_the_ID())->post_parent; $tname = get_post($pid)->post_title; global $wpdb; $request = "SELECT $wpdb->terms.term_id FROM $wpdb->terms where $wpdb->terms.name = '".$tname."'"; $request .= " ORDER BY term_id asc"; $tids = $wpdb->get_results($request); $tid = $tids[0]->term_id; $args = array( 'post_status' => 'publish', 'post_type' => 'osetin_recipe', 'orderby' => 'menu_order', 'order' => 'ASC', 'nopaging' => true, ); $args['tax_query'] = array(array('taxonomy' => 'recipes_by_product','field' => 'term_id','terms' =>$tid,'operator' => 'IN')); $my_query = new WP_Query( $args ); $i = 0;?> <aside id="product-recipes" class="with-ribbon widget widget_widget_tptn_pop"> <h3 class="widget-title"><span><?php echo $tname ;?>Recipes</span></h3> <div class="tptn_posts tptn_posts_widget"> <ul> <?php if($my_query->have_posts()):while($my_query->have_posts()&& $i<3):$my_query->the_post(); $my_content = $post->post_content; //$my_content = the_excerpt(); $my_content = substr($my_content,0,70)."..."; $my_title=$post->post_title; ?> <li><a href="<?php echo get_permalink($my_id); ?> " class="tptn_link"><?php echo get_the_post_thumbnail(206);?></a><span class="tptn_after_thumb"><a href="<?php echo get_permalink($my_id); ?>" class="tptn_link"><span class="tptn_title"><?php echo $my_title ?></span></a><span class="tptn_excerpt"><?php echo $my_content ?></span></span> </li> <?php $i++; endwhile; ?> </ul> <div class="tptn_clear"></div> <br> <div style = "text-align:center;" > <a href="<?php echo get_category_link($tid); ?>">More <?php echo $tname ;?> Recipes</a> </div> </div> </aside> <?php endif; ?>