我很新的PHP。请原谅,如果这是一个愚蠢的问题。 我已通过php将社交分享图标添加到我的博客。在主索引页面中,我添加了facebook,twitter和google plus共享图标,并在单个帖子中添加了更多图标。是否可以从一个PHP文件中调用不同的代码段?
我如何实施?
我创建了两个PHP文件social_main_index.php并在主索引模版social_single_post.php 然后,我添加的代码<? php include("social_main_index.php") ?>
在单模板后我添加的代码<? php include("social_single_post.php") ?>
我的问题
我可以创建一个包含代码的单个php文件并专门调用其中任何一个吗?
我在social_main_index.php代码
<?php include_once("custom_css.php") ?>
<div class="social-single">
<!--Facebook Share-->
<div id="likebutton"><iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo rawurlencode(get_permalink()); ?>&layout=button_count&show_faces=false&width=100&action=like&font=verdana&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>
<!--Google Plus Share-->
<div id="plusonebutton"><g:plusone href="<?php echo rawurlencode(get_permalink()); ?> "size="medium"></g:plusone></div>
<!--Twitter Share-->
<div id="twitterbutton"><script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script><div> <a href="http://twitter.com/share" class="twitter-share-button" data-url="<?php the_permalink() ?>" data-counturl="<?php the_permalink() ?>" data-text="<?php the_title(); ?>" data-via="nucleationin" data-related="nucleationin"></a></div>
</div>
</div>
我在social_single_post.php代码
<?php include_once("custom_css.php") ?>
<div class="social-single">
<!--Facebook Share-->
<div id="likebutton"><iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo rawurlencode(get_permalink()); ?>&layout=button_count&show_faces=false&width=100&action=like&font=verdana&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>
<!--Google Plus Share-->
<div id="plusonebutton"><g:plusone href="<?php echo rawurlencode(get_permalink()); ?> "size="medium"></g:plusone></div>
<!--Twitter Share-->
<div id="twitterbutton"><script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script><div> <a href="http://twitter.com/share" class="twitter-share-button" data-url="<?php the_permalink() ?>" data-counturl="<?php the_permalink() ?>" data-text="<?php the_title(); ?>" data-via="nucleationin" data-related="nucleationin"></a></div></div>
<!--Linkedin Share-->
<div id="linkedinshare"><script type="text/javascript" src="http://platform.linkedin.com/in.js"></script><script type="in/share" data-url="<?php the_permalink() ?>" data-counter="right"></script></div>
<!--Stumble Share-->
<div id="stumblebutton"><script src="http://www.stumbleupon.com/hostedbadge.php?s=1"></script></div>
</div>
是什么阻止你从创建,要么出回声的功能? – Daedalus 2013-03-10 06:20:21
@ Daedalus:正如我在我的文章中提到的,我对PHP很新。我通过查看主题设计代码了解了上述代码。实际上,我对php一无所知。我在尝试学习。 – Ian 2013-03-10 06:24:00