登录  /  注册
博主信息
博文 263
粉丝 3
评论 2
访问量 129358
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
wordpress 相关类型产品食谱分类调用(自写)
福哥的博客
原创
909人浏览过
          <?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;
?>


本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学