admin管理员组文章数量:1022949
i wanted to execute a code after the Content of each blog post. I just want it to be on posts and not on pages. I could execute simple html by the method but could not put the following content. Please help me out with a code to execute the following code at the end of content.
The code is simple in sense, but unlike most people who would echo html i need to have a mixture of php, JS and HTMl echoed after my content. The solution seems simple but i could not figure it out.
<div class="css">
<?php if ( should_display_link() ) : ?>
[subscribe-author-button]
<?php echo '<a class="btn" style="background-color:#1f1fff; border-radius:100px;" href="'.site_url('chat/').'?new-message&to='.get_the_author_meta( 'user_login' ).'">Chat</a>' ; ?>
<?php endif; ?>
[simple-author-box]
<?php if ($post->post_status == "publish") { ?>
<h4>[post-views]</h4>
<?php } else {echo "<span></span>";} ?>
<?php if ( should_display_link() ) : ?>
<a class="btn" href="" data-mode="popup" style="background-color:#DB4437;color:white;border-radius:25px;" data-hide-headers=true data-hide-footer=true data-submit-close-delay="5" target="_blank">Report Content </a> <script> (function() { var qs,js,q,s,d=document, gi=d.getElementById, ce=d.createElement, gt=d.getElementsByTagName, id="typef_orm_share", b="/"; if(!gi.call(d,id)){ js=ce.call(d,"script"); js.id=id; js.src=b+"embed.js"; q=gt.call(d,"script")[0]; q.parentNode.insertBefore(js,q) } })() </script>
<?php endif; ?>
</div>
i wanted to execute a code after the Content of each blog post. I just want it to be on posts and not on pages. I could execute simple html by the method but could not put the following content. Please help me out with a code to execute the following code at the end of content.
The code is simple in sense, but unlike most people who would echo html i need to have a mixture of php, JS and HTMl echoed after my content. The solution seems simple but i could not figure it out.
<div class="css">
<?php if ( should_display_link() ) : ?>
[subscribe-author-button]
<?php echo '<a class="btn" style="background-color:#1f1fff; border-radius:100px;" href="'.site_url('chat/').'?new-message&to='.get_the_author_meta( 'user_login' ).'">Chat</a>' ; ?>
<?php endif; ?>
[simple-author-box]
<?php if ($post->post_status == "publish") { ?>
<h4>[post-views]</h4>
<?php } else {echo "<span></span>";} ?>
<?php if ( should_display_link() ) : ?>
<a class="btn" href="https://adityaagarwal3.typeform/to/Lin6FB" data-mode="popup" style="background-color:#DB4437;color:white;border-radius:25px;" data-hide-headers=true data-hide-footer=true data-submit-close-delay="5" target="_blank">Report Content </a> <script> (function() { var qs,js,q,s,d=document, gi=d.getElementById, ce=d.createElement, gt=d.getElementsByTagName, id="typef_orm_share", b="https://embed.typeform/"; if(!gi.call(d,id)){ js=ce.call(d,"script"); js.id=id; js.src=b+"embed.js"; q=gt.call(d,"script")[0]; q.parentNode.insertBefore(js,q) } })() </script>
<?php endif; ?>
</div>
Share
Improve this question
edited Apr 19, 2019 at 13:55
asked Feb 28, 2019 at 3:22
user160406user160406
1 Answer
Reset to default 0You can try my approach which is used to do your requirement:
function themename_your_content_after($content) {
if( is_single() ):
ob_start();
?>
<div class="css">
<?php if ( should_display_link() ) : ?>
[subscribe-author-button]
<?php echo '<a class="btn" style="background-color:#1f1fff; border-radius:100px;" href="'.site_url('chat/').'?new-message&to='.get_the_author_meta( 'user_login' ).'">Chat</a>' ; ?>
<?php endif; ?>
[simple-author-box]
<?php if ($post->post_status == "publish") { ?>
<h4>[post-views]</h4>
<?php } else {echo "<span></span>";} ?>
<?php if ( should_display_link() ) : ?>
<a class="btn" href="https://adityaagarwal3.typeform/to/Lin6FB" data-mode="popup" style="background-color:#DB4437;color:white;border-radius:25px;" data-hide-headers=true data-hide-footer=true data-submit-close-delay="5" target="_blank">Report Content </a> <script> (function() { var qs,js,q,s,d=document, gi=d.getElementById, ce=d.createElement, gt=d.getElementsByTagName, id="typef_orm_share", b="https://embed.typeform/"; if(!gi.call(d,id)){ js=ce.call(d,"script"); js.id=id; js.src=b+"embed.js"; q=gt.call(d,"script")[0]; q.parentNode.insertBefore(js,q) } })() </script>
<?php endif; ?>
</div>
<?php
$code_content = ob_get_clean();
$content .= $code_content;
endif;
return $content;
}
add_filter('the_content', 'themename_your_content_after');
i wanted to execute a code after the Content of each blog post. I just want it to be on posts and not on pages. I could execute simple html by the method but could not put the following content. Please help me out with a code to execute the following code at the end of content.
The code is simple in sense, but unlike most people who would echo html i need to have a mixture of php, JS and HTMl echoed after my content. The solution seems simple but i could not figure it out.
<div class="css">
<?php if ( should_display_link() ) : ?>
[subscribe-author-button]
<?php echo '<a class="btn" style="background-color:#1f1fff; border-radius:100px;" href="'.site_url('chat/').'?new-message&to='.get_the_author_meta( 'user_login' ).'">Chat</a>' ; ?>
<?php endif; ?>
[simple-author-box]
<?php if ($post->post_status == "publish") { ?>
<h4>[post-views]</h4>
<?php } else {echo "<span></span>";} ?>
<?php if ( should_display_link() ) : ?>
<a class="btn" href="" data-mode="popup" style="background-color:#DB4437;color:white;border-radius:25px;" data-hide-headers=true data-hide-footer=true data-submit-close-delay="5" target="_blank">Report Content </a> <script> (function() { var qs,js,q,s,d=document, gi=d.getElementById, ce=d.createElement, gt=d.getElementsByTagName, id="typef_orm_share", b="/"; if(!gi.call(d,id)){ js=ce.call(d,"script"); js.id=id; js.src=b+"embed.js"; q=gt.call(d,"script")[0]; q.parentNode.insertBefore(js,q) } })() </script>
<?php endif; ?>
</div>
i wanted to execute a code after the Content of each blog post. I just want it to be on posts and not on pages. I could execute simple html by the method but could not put the following content. Please help me out with a code to execute the following code at the end of content.
The code is simple in sense, but unlike most people who would echo html i need to have a mixture of php, JS and HTMl echoed after my content. The solution seems simple but i could not figure it out.
<div class="css">
<?php if ( should_display_link() ) : ?>
[subscribe-author-button]
<?php echo '<a class="btn" style="background-color:#1f1fff; border-radius:100px;" href="'.site_url('chat/').'?new-message&to='.get_the_author_meta( 'user_login' ).'">Chat</a>' ; ?>
<?php endif; ?>
[simple-author-box]
<?php if ($post->post_status == "publish") { ?>
<h4>[post-views]</h4>
<?php } else {echo "<span></span>";} ?>
<?php if ( should_display_link() ) : ?>
<a class="btn" href="https://adityaagarwal3.typeform/to/Lin6FB" data-mode="popup" style="background-color:#DB4437;color:white;border-radius:25px;" data-hide-headers=true data-hide-footer=true data-submit-close-delay="5" target="_blank">Report Content </a> <script> (function() { var qs,js,q,s,d=document, gi=d.getElementById, ce=d.createElement, gt=d.getElementsByTagName, id="typef_orm_share", b="https://embed.typeform/"; if(!gi.call(d,id)){ js=ce.call(d,"script"); js.id=id; js.src=b+"embed.js"; q=gt.call(d,"script")[0]; q.parentNode.insertBefore(js,q) } })() </script>
<?php endif; ?>
</div>
Share
Improve this question
edited Apr 19, 2019 at 13:55
asked Feb 28, 2019 at 3:22
user160406user160406
1 Answer
Reset to default 0You can try my approach which is used to do your requirement:
function themename_your_content_after($content) {
if( is_single() ):
ob_start();
?>
<div class="css">
<?php if ( should_display_link() ) : ?>
[subscribe-author-button]
<?php echo '<a class="btn" style="background-color:#1f1fff; border-radius:100px;" href="'.site_url('chat/').'?new-message&to='.get_the_author_meta( 'user_login' ).'">Chat</a>' ; ?>
<?php endif; ?>
[simple-author-box]
<?php if ($post->post_status == "publish") { ?>
<h4>[post-views]</h4>
<?php } else {echo "<span></span>";} ?>
<?php if ( should_display_link() ) : ?>
<a class="btn" href="https://adityaagarwal3.typeform/to/Lin6FB" data-mode="popup" style="background-color:#DB4437;color:white;border-radius:25px;" data-hide-headers=true data-hide-footer=true data-submit-close-delay="5" target="_blank">Report Content </a> <script> (function() { var qs,js,q,s,d=document, gi=d.getElementById, ce=d.createElement, gt=d.getElementsByTagName, id="typef_orm_share", b="https://embed.typeform/"; if(!gi.call(d,id)){ js=ce.call(d,"script"); js.id=id; js.src=b+"embed.js"; q=gt.call(d,"script")[0]; q.parentNode.insertBefore(js,q) } })() </script>
<?php endif; ?>
</div>
<?php
$code_content = ob_get_clean();
$content .= $code_content;
endif;
return $content;
}
add_filter('the_content', 'themename_your_content_after');
本文标签: pluginsHow to echo a PHP Code After the Content
版权声明:本文标题:plugins - How to echo a PHP Code After the Content 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745572786a2156836.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论