AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

Filter by custom fields

Topic prefix

AI Assistant
Notifications
Clear all

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

3 Posts
2 Users
1 Reactions
1,932 Views
Posts: 10
Topic starter
Translate β–Ό
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@moisb)
Active Member
Joined: 7 years ago
[#8321]

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: 5774
 Sofy
Admin
Translate β–Ό
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@sofy)
Support Team
Joined: 8 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
Translate β–Ό
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@moisb)
Active Member
Joined: 7 years ago

thank you Sofy, worked perfectly. 🤗Β 


Share: