改造HotNews Pro主题之增加文章页广告位
0 条评论HotNew Pro主题是个功能强大,且人性化的优秀主题,但文章内容上面没有广告位,我们有时需要在那个位置添加广告,往往就会使用一些广告管理插件.都说插件多了影响网站速度,那除了插件我们怎么给文章添加广告位呢?
下面说一下怎样在HotNew Pro主题文章内容上面添加广告位的方法.
1.新建一个文件adp.php,复制下面代码到里面,保存文件上传文件到HotNewspro/includes/目录下.1
2
3
4
5<div class="adt">
<div class="ad_c">echo stripslashes(get_option('swt_adpc'));
<div class="clear"></div>
</div>
</div>
2.修改后台控制HotNewspro/includes/theme_options.php 添加这是后台控制广告的找到下面代码1
2
3
4
5
6
7
8
9
10
11
12array( "name" => "是否显示正文底部广告",
"desc" => "默认显示",
"id" => $shortname."_adt",
"type" => "select",
"std" => "Hide",
"options" => array("Display", "Hide")),
array( "name" => "输入正文底部广告代码",
"desc" => "",
"id" => $shortname."_adtc",
"type" => "textarea",
"std" => '<a href="http://faq.wopus.org/" target="_blank"><img src="http://photo.staticsdo.com/a1/184/278/104/63440-772704496-8_765.jpg" alt="Wopus问答" /></a>'),
在下面添加1
2
3
4
5
6
7
8
9
10
11
12array( "name" => "是否显示正文上面广告",
"desc" => "默认显示",
"id" => $shortname."_adp",
"type" => "select",
"std" => "Hide",
"options" => array("Display", "Hide")),
array( "name" => "输入正文上面广告代码",
"desc" => "",
"id" => $shortname."_adpc",
"type" => "textarea",
"std" => '<a href="http://faq.wopus.org/" target="_blank"><img src="http://photo.staticsdo.com/a1/184/278/104/63440-772704496-8_765.jpg" alt="Wopus问答" /></a>'),
3.修改文章页面HotNewspro/single.php文件,找到
1 | 'Read more...'); the_content( |
改成如下内容1
2
3
4
5
6
7
8
9
10
11
12
13
14<div class="entry">
<div id="entry">
if (get_option('swt_adp') == 'Hide') {
echo ''; } {
else { include(TEMPLATEPATH . '/includes/adp.php'); } }
'Read more...'); the_content(
array( 'before' => '<p class="pages">' . __( '日志分页:'), 'after' => '</p>' ) ); wp_link_pages(
<div class="clear"></div>
</div>
if (get_option('swt_adt') == 'Hide') {
echo ''; } {
else { include(TEMPLATEPATH . '/includes/adt.php'); } }
<div class="clear"></div>
</div>
这就好了,后台主题管理>广告管理处就可以看到”输入正文上面广告代码”的选项菜单了.