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 软件定义网络mininet和onos控制器问题
  • ¥15 微信小程序 用oss下载 aliyun-oss-sdk-6.18.0.min client报错
  • ¥15 ArcGIS批量裁剪
  • ¥15 labview程序设计
  • ¥15 为什么在配置Linux系统的时候执行脚本总是出现E: Failed to fetch http:L/cn.archive.ubuntu.com
  • ¥15 Cloudreve保存用户组存储空间大小时报错
  • ¥15 伪标签为什么不能作为弱监督语义分割的结果?
  • ¥15 编一个判断一个区间范围内的数字的个位数的立方和是否等于其本身的程序在输入第1组数据后卡住了(语言-c语言)
  • ¥15 Mac版Fiddler Everywhere4.0.1提示强制更新
  • ¥15 android 集成sentry上报时报错。