网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

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

GG网络技术分享 2025-03-18 16:12 12


问题描述:

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..

图片转代码服务由CSDN问答提供

感谢您的意见,我们尽快改进~

功能建议

我想在bootstrap 4列中显示一个wordpress类别帖子.. </ p>

我希望输出就像这个链接。 https://addapinch.com/ 在底部滚动,您会找到我想要的确切输出.. < / p>

</ div>

网友观点:

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>\';

?>

标签:

提交需求或反馈

Demand feedback