Blogger Information
Blog 263
fans 3
comment 2
visits 113281
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
wordpress 相关类型产品食谱分类调用(自写)
福哥的博客
Original
764 people have browsed it
          <?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;
?>


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post