2

我最近使用 fishpig 插件包含了一个完全集成到 magento 中的 wordpress 安装。我正在努力限制主页上帖子的字符/字数。

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”并将其包含在主页块中的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,所以我不能采用通常的根。

对此的任何帮助将不胜感激。

4

3 回答 3

3

最近使用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>
于 2013-01-24T15:48:47.877 回答
1

您必须编辑 categoryposts.phtml。换行

<p class="post-excerpt"><?php echo $post->getPostExcerpt() ?></p> 

<p class="post-excerpt"><?php  echo substr($post->getPostExcerpt(),0,$post["excerpt_size"]) ?> </p>

如果您有图像,请确保将长度从 30 设置为 700 之类的高值

于 2013-05-20T07:56:01.820 回答
0

对于所有视觉学习者......您也可以通过单击“创建新帖子”页面上厨房水槽内的“插入更多标签”图标手动完成。

在此处输入图像描述

只需选择一个换行区域,通常 4-6 个段落行就可以了……然后单击按钮。

于 2013-11-05T05:37:05.273 回答