【问题标题】:Display author avatar in posts/homepage after wordpress magento integration在 wordpress magento 集成后在帖子/主页中显示作者头像
【发布时间】:2013-10-16 14:47:19
【问题描述】:

我正在使用 FishPig 扩展将 wordpress 集成到 magento 中,一切正常。现在我想在每篇文章中显示作者 gravatar 以及在主页上每篇文章标题下的小作者图片。这是博客网址 - www.postmygreetings.com/blog/

编辑:

我正在使用此代码在主页上的每个帖子下显示作者姓名、发布日期和标签现在我还想显示小作者图片:

<?php echo stripslashes($this->__('This entry was posted in %s and tagged %s on %s<span class=\"by-author\"> by %s</span>.', 
         $this->getCategoryString($post), 
         $this->getTagString($post), 
         $post->getPostDate(), 
         $post->getAuthor()->getDisplayName())
  ) ?>

【问题讨论】:

  • 你能分享一下你想在哪里显示gravatar的代码吗?请在其中包含您用于获取帖子标题的代码,获取作者图像是相似的
  • 我正在使用此代码在主页上的每个帖子下显示作者姓名,发布日期和标签现在我还想显示小作者图像&lt;?php echo stripslashes($this-&gt;__('This entry was posted in %s and tagged %s on %s&lt;span class=\"by-author\"&gt; by %s&lt;/span&gt;.', $this-&gt;getCategoryString($post), $this-&gt;getTagString($post), $post-&gt;getPostDate(), $post-&gt;getAuthor()-&gt;getDisplayName())) ?&gt;

标签: wordpress magento


【解决方案1】:

要获取用户头像,您必须创建一个类似于 wordpress get_avatar 的函数,您可以找到它的 code here

有了这个函数后,只需使用正确的参数调用它,它应该可以工作......

您可以从已经可以使用的对象中获取参数,例如

$post->getAuthor()->getDisplayName())

【讨论】:

  • 你知道在wordpress-magento集成后在哪里添加新功能,因为wp文件夹中的默认funvtions.php文件不起作用吗?
  • @SatinderSingh 我不确切知道,但检查什么函数为 $post 变量赋值检查它在哪里,看看你是否可以把你的自定义函数放在那里(如果它是正确的地方...... )
猜你喜欢
  • 2017-08-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-27
  • 1970-01-01
  • 2016-01-29
  • 2014-05-13
  • 1970-01-01
相关资源
最近更新 更多