Shopp产品/类别链接快捷码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Shopp产品/类别链接快捷码相关的知识,希望对你有一定的参考价值。
Add two new shortcodes to create Shopp product/category links in an easy way.**USAGE:**
The following shortcodes will now be available along your posts, pages and text widgets
[productlink id='' text=''] (Text is optional, if omitted the product name will appear)
[categorylink id='' text=''] (Text is optional, if omitted the category name will appear)
# !SHOPP SHORTCODES # PASTE THIS CODE IN THE functions.php FILE OF YOUR WP THEME function link_shopp_category($data) { if($id) : shopp('catalog','category','id='.$id.'&load=true'); if(shopp('category','id', 'return=true')) : $url = shopp('category','url','return=true'); if($text=="") $text = shopp('category','name','return=true'); shopp('catalog','category','reset=true'); return "<a href='$url' title='$text'>$text</a>"; else: return "<p>Error: Category not found."; endif; else : return "<p>There is an error with your syntax.</p>"; endif; } # end menu_link add_shortcode('categorylink', 'link_shopp_category'); function link_shopp_product($data) { if($id) : shopp('catalog','product','id='.$id.'&load=true'); if(shopp('product','found')) : $url = shopp('product','url','return=true'); if($text=="") $text = shopp('product','name','return=true'); shopp('catalog','product','reset=true'); return "<a href='$url' title='$text'>$text</a>"; else : return "<p>Error: Product not found</p>"; endif; else : return "<p>There is an error with your syntax.</p>"; endif; } # end link_shopp_product add_shortcode('productlink', 'link_shopp_product'); # Use shortcodes in text widgets. add_filter('widget_text', 'do_shortcode');
以上是关于Shopp产品/类别链接快捷码的主要内容,如果未能解决你的问题,请参考以下文章
用于 WordPress 的 PHP 片段,用于获取所有产品子类别