2015-04-12 77 views
1

我是新的wordpress插件&在我的笔记本电脑上我的wamp服务器上运行wordpress,我写了&在我的wordpress网站(站点名称:lifyog)我的桌面。写在插件中的函数应该为每个帖子添加图像,但它不起作用。请帮助纠正代码。插件激活,但不能在桌面上的wordpress工作

我已检查图片来源这很关键。

我的插件是在以下地址:

wamp/www/wordpress/wp-content/plugins/Wpplugin 

文件名是addimage.php

插件的代码是为下:

<?php 
/* 
Plugin Name: Add Image 
Plugin URL:http//wordpress 
Version: 1.0 
Author: wordpress 
Author URL: http://localhost/wordpress 
Description: This plugin automatically adds an image at the beginning of every post 
*/ 

function addImage($post) 
{ 
$imagewithtext="<img src='http://localhost/wordpress/wp-content/themes/twentyfifteen/Images/veer.jpg' height='70px' width='70px' align='left'>"; 
$imagewithtext=$post; 
return $imagewithtext; 

} 

add_filter("the_content","addImage"); 
?> 

回答

1

的$ imagewithtext变量声明上线14覆盖$ linewithtext变量,你已经写在行13上。

可以更改等号“=”,以点等号“=”,这将帮助你在$后变量的值添加到$ imagewithtext变量,而不是覆盖它

$imagewithtext .= $post;$imagewithtext = $post;

我相信这会做诡计

+0

非常感谢你的工作 – user3811050

相关问题