Notifications
Clear all

wpForo 1.x.x [Solved] Which Wordpress conditional tags they work with wpForo?

3 Posts
2 Users
1 Likes
1,148 Views
Posts: 10
Topic starter
(@moisb)
Active Member
Joined: 6 years ago

Hi. Which conditional tags they work with wpForo? 🤔 

I need to add javascript snippet only in forums and topic/replies, via php function.

I'm trying this way, but I already tested with post type, page, taxonomy etc.:

function add_viglink_wpforo() {

if (class_exists('wpForo')) {
if (is_page_template( 'forum.php' )) {
?>
<script type="text/javascript">
var vglnk = {key: 'ed974cd4d44d08a2e087879f6eb53678'};
(function(d, t) {
var s = d.createElement(t);
s.type = 'text/javascript';
s.async = true;
s.src = '//cdn.viglink.com/api/vglnk.js';
var r = d.getElementsByTagName(t)[0];
r.parentNode.insertBefore(s, r);
}(document, 'script'));
</script>
<?php
}
}
}
add_action( 'wp_footer', 'add_viglink_wpforo');
2 Replies
Sofy
Posts: 4308
 Sofy
Admin
(@sofy)
Support Team
Joined: 6 years ago

Hi @moisb,

wpForo doesn’t use custom post types, so the topics and posts are not stored in the wp_posts table, wpForo has its own tables for topics ( _wpforo_topics) and posts ( _wpforo_posts).
Custom post types are being stored in the wp_posts and wp_postmeta table. All what you have in WP are already there. This becomes very large and heavy. If you familiar with MySQL you should know that it’s dozens of times faster to get x, y and z data from the same _wpforo_posts table than get those from two wp_post and wp_postmeta tables. 

In this case, you should use this code:

if( in_array( WPF()->current_object['template'], array('topic', 'post') ) ){
//custom code
}
Posts: 10
Topic starter
(@moisb)
Active Member
Joined: 6 years ago

thank you Sofy, worked perfectly. 🤗Â