【问题标题】:Wordpress plugin - How off my plugin in wordpress home pageWordpress 插件 - 如何在 wordpress 主页中关闭我的插件
【发布时间】:2011-08-10 01:30:29
【问题描述】:

我做了一个简单的插件,我想只在完整的帖子下面而不是在主页上使用这个插件。插件仅从我的数据库中读取图片并将图片放在帖子下方。

   function get_image_big() 

   {             
     echo file_get_contents('http://demotivators.us/widget/big_demotivators.php');        
   }

   add_action( 'loop_end', 'get_image_big');

wordpress 主页中所有主题的这个脚本怎么样? 为我的英语道歉。

【问题讨论】:

    标签: php wordpress wordpress-theming


    【解决方案1】:

    使用is_home()is_front_page() 调用来检测主页是否显示。

    【讨论】:

      【解决方案2】:

      您需要将代码添加到主题模板(只要您想显示图像)。 例如,如果您想在单个帖子的末尾显示图像,则需要在此处添加函数调用。它看起来像这样:

      if ( function_exists( 'get_image_big' ) ) { get_image_big(); }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多