dosgy00204 2019-07-28 14:55
浏览 51
已采纳

如何在Wordpress循环中显示4个Bootstrap列[关闭]

i want to display a wordpress category post inside bootstrap 4 columns..

I want the output just like this link. https://addapinch.com/ scroll at the bottom and you will find the exact output which i want..

  • 写回答

1条回答 默认 最新

  • douya1248 2019-07-28 15:53
    关注

    I don't like to give end to end solution, but here is the one part from my code which loops through the categories and shows them on the page. You can re-edit them a bit and you will get a desired output:

    <?php
    echo '<ul class="nav nav-tabs" role="tablist">';
    
    $args = array(
        'hide_empty'=> 1,
        'orderby' => 'name',
        'order' => 'ASC'
    );
    
    $categories = get_categories($args);
    
    foreach($categories as $category) { 
    
        echo '<li><a href="#' . $category->name.'" role="tab" data-toggle="tab">' .      
        $category->name.'</a></li>';
        $cat_name = $category->name;
    
    } 
    echo '</ul>';
    echo '<div class="tab-content">';
    foreach($categories as $category) { 
        echo '<div class="tab-pane" id="' . $category->name.'">';
    
    $the_query = new WP_Query(array(
        'post_type' => 'acme_product',
        'posts_per_page' => 100,
        'category_name' => $category->slug
    )); 
    while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    
    <h1><?php the_title(); ?></h1>
    
    <?php endwhile; 
    wp_reset_postdata();
    wp_reset_query();
    ?>   
    
    <?php } 
    echo '</div>';
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题