我最近使用fishpig插件安装了一个wordpress,并完全集成到magento中。我正在努力限制主页上帖子的字符/字数。
FishPig 记录了一个用于发布摘录的小部件,包括以下代码:
<block type="wordpress/sidebar_widget_posts" name="wordpress.widget.recent_posts" as="recent_posts" template="wordpress/sidebar/widget/categoryposts.phtml">
<action method="setTitle"><title>Latest Posts</title></action>
<action method="setPostCount"><post_count>5</post_count></action>
<action method="setExcerpt"><display>on</display></action>
<action method="setExcerptLength"><length>30</length></action>
<action method="setDate"><date>on</date></action>
<action method="setCommentNum"><comments>on</comments></action>
</block>
我假设我可以将“setExcerptLength”模仿为“setPostLength”,并将其包含在主页 block 中的 wordpress.xml 中
<block type="wordpress/post_list" name="wordpress_post_list" template="wordpress/post/list.phtml">
<block type="wordpress/post_list_pager" name="wordpress_post_list_pager">
<action method="setPostLength"><length>30</length></action>
</block>
</block>
但是这些似乎没有效果。
我假设所有 wordpress 功能都已完全集成转换为 xml,因此我无法采用通常的根。
对此的任何帮助将不胜感激。
最佳答案
最近使用fishpig插件将wordpress集成到magento中后,我还发现摘录长度没有效果。
无需过多深入研究代码,我的解决方案如下。
不要使用 xml,直接在页面内容中插入以下内容。确保删除您添加的任何 xml。
{{block type="wordpress/sidebar_widget_posts" name="wordpress.widget.recent_posts" post_count="5" title="Latest Blogs" excerpt="on" excerpt_length="250" date="off" comment_num="off" template="wordpress/sidebar/widget/post-hp.phtml"}}
在您的模板目录中
app/design/frontend/default/your_template/template/wordpress/sidebar/widget/
创建一个新文件,post-hp.phtml
将categoryposts.phtml 的内容复制到这个新文件中。
查找并替换
<p class="post-excerpt"><?php echo $post->getPostExcerpt() ?></p>
与
<p class="post-excerpt"><?php $content = $post->getPostExcerpt(); $content = strip_tags($content); echo substr($content, 0, 250); ?> ...</p>
关于xml - Wordpress 和 Magento 完全集成的主页帖子的字符/字数限制 (fishpig),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14391168/