亲爱的StackOverflow朋友, 在Wordpress电子商店中,我们使用Woocommerce及其扩展插件Woocommerce Brand Addon。WordPresspress:摘录仅针对Woocommerce品牌页面
我想这个代码(位于functions.php中)被应用只Woocommerce品牌页面:代码,它的工作在Woocommerce品牌但它也适用于其他类别/档案
我玩'分类'和'包括',插入品牌的ID,但没有结果。这是我的最后一次尝试。
add_action('woocommerce_after_shop_loop_item_title', 'lk2_woocommerce_product_excerpt', 35, 2);
if (!function_exists('lk2_woocommerce_product_excerpt'))
{
function lk2_woocommerce_product_excerpt()
{
$content_length = 20;
global $post;
$args = array(
'include' => '120,121,122,123,124,125,126,127',
'taxonomy' => 'product_brand',
);
$content = $post->post_excerpt;
$wordarray = explode(' ', $content, $content_length + 1);
if(count($wordarray) > $content_length) :
array_pop($wordarray);
array_push($wordarray, '...');
$content = implode(' ', $wordarray);
$content = force_balance_tags($content);
endif;
echo "<span class='excerpt'><p>$content</p></span>";
}
}
不幸的是,我们还没有购买域名,所以我不能告诉你一个链接。
我可以用css修复输出,但我更愿意直接从代码中解决。 你能帮我找到修复我的错误的方向吗?谢谢你的时间!
“品牌”是一种分类吗?你不能在函数内使用条件逻辑吗? – helgatheviking 2014-10-11 21:45:08
@helgatheviking抱歉提问,但什么是'taxonomy'? – Yang 2014-10-12 23:58:09
[分类法](http://codex.wordpress.org/Taxonomies)是将事物分组在一起的一种方法。标签和类别是帖子的内置分类法。产品标签和产品类别是由WooCommerce创建的产品的分类标准。 – helgatheviking 2014-10-13 09:41:56