2

最近、fishpig プラグインを使用して、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」として投稿に模倣し、ホームページブロック内の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>

ただし、これらは効果がないようです。

すべてのワードプレス機能が完全統合で 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 に答える