ludalex
Forum Replies Created
Viewing 4 replies - 1 through 4 (of 4 total)
-
change get_topic_ID() in class.ipbcomments.php with this:
function get_topic_ID () { $post_ID = get_the_ID(); $meta = get_post_meta($post_ID,'forum_topic_meta'); if(!empty($meta)) { extract($meta[0]); return $topic_id; } else { return false; } }
and in comments.php or whatever you want:
$ipb_comments = new WP_IPBComments; echo "wp post: ". get_the_ID() . "<br>"; $topicID = $ipb_comments->get_topic_ID(); if($topicID) { echo "topic id:". $topicID; echo "replies number: ". $ipb_comments->get_replies_number($topicID); } else { echo "Forum post doesn't exist."; }
golgoth, have you checked if the posts that give you the error got posted on the forum using IPB.Comments?
That could be the problem.I did it my myself:
add these two functions to class.ipbcomments.php:function get_replies_number( $topic_id ) { if ( ! (isset($this->options['ipb_field_path']) OR file_exists($this->options['ipb_field_path'])) ) { return FALSE; } ini_set( 'display_errors', 0 ); // Keep the board from redirecting // https://community.invisionpower.com/tracker/issue-26224-issues-with-ssiphp/ define('CCS_GATEWAY_CALLED',FALSE); require_once( $this->options['ipb_field_path'] .'/initdata.php' ); require_once( IPS_ROOT_PATH .'sources/base/ipsController.php' ); require_once( IPS_ROOT_PATH .'sources/base/ipsRegistry.php' ); $registry = ipsRegistry::instance(); $registry->init(); // build the select statement, skip the original post, we just want the replies $registry->DB()->build( array( 'select' => 'posts', 'from' => 'topics', 'where' => 'tid = ' . $topic_id ) ); $result = $registry->DB()->execute(); if ( $result ) { $num = $registry->DB()->fetch(); return $num['posts']; } }
and:
function get_topic_ID () { $post_ID = get_the_ID(); $meta = get_post_meta($post_ID,'forum_topic_meta'); extract($meta[0]); return $topic_id; }
And anywhere on your wordpress page, for example in comments.php, you can display how many replies has the topic corresponding to the post with this:
$ipb_comments = new WP_IPBComments; echo "topic id: ".$topicID = $ipb_comments->get_topic_ID(); echo "replies number: ". $ipb_comments->get_replies_number($topicID);
Shouldn’t this be really easy with the XML-RPC Api?
Anyway, any updates?
Viewing 4 replies - 1 through 4 (of 4 total)