简体   繁体   English

需要帮助重新排列此代码(适用于 Wordpress single.php)

[英]Need help rearranging this code (for Wordpress single.php)

I need help with rearranging the code in my single.php file for my premium theme on Wordpress.我需要帮助重新排列我的 single.php 文件中的代码以用于我在 Wordpress 上的高级主题。

Currently, posts on my Wordpress site feature a Facebook comment box in the Related Posts section, with the default Wordpress comment box under the Leave A Comment section.目前,我的 Wordpress 网站上的帖子在“相关帖子”部分中有一个 Facebook 评论框,在“发表评论”部分下有默认的 Wordpress 评论框。 I would like to either remove the default Wordpress comment box completely and replace it with the Facebook one (so that it is under the Leave A Comment heading), or I would like to have both the Facebook and Wordpress comment boxes under the Leave A Comment heading, with the Facebook one appearing on top.我想完全删除默认的 Wordpress 评论框并将其替换为 Facebook 评论框(以便它位于“发表评论”标题下),或者我想在“发表评论”下同时拥有 Facebook 和 Wordpress 评论框标题,Facebook 出现在顶部。

I was not able to insert the entire single.php file code into Stack Overflow (as I seen that some of the code is coming up unformatted due to Stack Overflow limitations, I believe), so here's a download link to download the .php from ShareBeast.我无法将整个 single.php 文件代码插入到 Stack Overflow 中(我相信,由于 Stack Overflow 的限制,我看到某些代码未格式化),所以这里有一个下载链接,可以从中下载 .php分享野兽。

Now here's the suggestion/"hint" I received from the theme's developer about this matter.现在这是我从主题开发人员那里收到的关于此事的建议/“提示”。

Go to single.php Go to line 83转到 single.php 转到第 83 行

This code is FB: if($bd_data['post_fb_comments_box']){ ?> (function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));这段代码是 FB: if($bd_data['post_fb_comments_box']){ ?> (function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id) )) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js , fjs); }(document, 'script', 'facebook-jssdk')); ' ."\\n"; ' ."\\n"; } }

================== ==================

This code is wordpress:这段代码是wordpress:

if($bd_data['post_comments_box']){ wp_reset_query(); if($bd_data['post_comments_box']){ wp_reset_query(); comments_template();评论模板(); } }

Here's an example of my a post on my site that uses both comment boxes.是我在我的网站上使用两个评论框的帖子示例

If anyone could rearrange the code as I described and either upload the .php and send me a link to it or post it here I guess, that would be a great help.如果有人可以按照我的描述重新排列代码,然后上传 .php 并向我发送指向它的链接或将其张贴在这里,我想这将是一个很大的帮助。 Thanks in advance.提前致谢。

In wordpress, comment_form_field_comment hook used to change the default comment form behavior or custom form.在 wordpress 中,comment_form_field_comment 挂钩用于更改默认的评论表单行为或自定义表单。 And we initialize the function in 'init' hook to load on wordpress initially我们在 'init' 钩子中初始化函数以最初加载到 wordpress

In function.php在函数.php

add_action('init', 'custom_comment_form');

function custom_comment_form() {
   add_filter( 'comment_form_field_comment', 'facebook_comment_form' );
}

function facebook_comment_form( $field ) {
   //your facebook comment form, stored in $field variable

   return $field;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM