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

 Sort Search Results by:

AI Assistant
Notifications
Clear all

[Solved] Sticky Topics Order - Simple Layout

9 Posts
6 Users
2 Reactions
1,820 Views
Posts: 19
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
(@fastertomaster)
Eminent Member
Joined: 6 years ago
[#13151]

Hi team,

Is there a way to make this work: https://wpforo.com/community/general-discussions/sticky-topics-order-updated-function/

For simple (not threaded) forums and sub-forums?

Thanks, A


8 Replies
Posts: 1008
Moderator
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
(@martin)
Support Team
Joined: 10 years ago

Hi @fastertomaster,

There is no a general solution for all places, it depends on the forum layout and the page (home forum list or in forum topic list). Please specify an exact layout and an exact page.


1 Reply
(@fastertomaster)
Joined: 6 years ago

Eminent Member
Posts: 19
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

Thanks @martin - I'd love to do this for an in-forum topic list using the simplified layout.

I've already got all my IDs and the previous function installed. Just need the tweak to make it work for that view. 🤗

Really appreciate the help!


Robert
Posts: 10749
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
(@robert)
Support Team
Joined: 3 months ago

Hi @fastertomaster,

For the Simplified forum layout you can use this code in the current active WordPress theme functions.php file. If you have an active WordPress child theme, you should only use the child theme functions.php file. Once you put this code and saved. Go to Dashboard > Forums > Dashboard and click on the [Delete All Caches] button.

 

function wpforo_custom_sticky_topic_order( $current_object, $wpf_url_parse ){

$rules = array();

//$rules[ ForumID ] = array( First TopicID, Second TopicID );
$rules[4] = array(19, 6);
$rules[7] = array(26, 63, 68);

if( function_exists('WPF') && isset($current_object['template']) ){
if( $current_object['template'] == 'topic' && wpfval($current_object, 'topics') ){
$topics = $current_object['topics'];
$tmp = array(); $ordered = array();
$forumid = $current_object['forumid'];
if( !empty( $rules ) && isset( $rules[$forumid] ) ){
foreach( $topics as $key => $topic ){if( isset($topic['topicid'])) {$tmp[$topic['topicid']] = $topic;}}
if( !empty($tmp) ){foreach( $rules[$forumid] as $topicid ){if( isset($tmp[$topicid]) ) {$ordered[] = $tmp[$topicid]; unset($tmp[$topicid]);}}}
$topics = array_merge($ordered, $tmp);
$topics = array_values($topics);
if(!empty($topics)) $current_object['topics'] = $topics;
}
}
}

return $current_object;
}
add_filter('wpforo_after_init_current_object', 'wpforo_custom_sticky_topic_order', 10, 2);

 

This is the part where you should edit and change forum/topic IDs. For example, you want to set topicid 19 first, then topicid 6 second in forumid 4 you should add/edit the row this way:


$rules[4] = array(19, 6);

If you don't have other forums where you want to add sticky topic ordering rules just remove the second line. I added this to show you can add as much $rules as you want:

$rules[7] = array(26, 63, 68);

 

 


Posts: 19
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
(@fastertomaster)
Eminent Member
Joined: 6 years ago

Works perfectly. Thank you for the awesome continued support.

Review left on the plugin page:

https://wordpress.org/support/topic/superb-support-77/#new-topic-0

Thank you!


2 Replies
Sofy
 Sofy
Admin
(@sofy)
Joined: 8 years ago

Support Team
Posts: 5776
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

Thank you for the review fastertomaster.


Robert
Admin
(@robert)
Joined: 3 months ago

Support Team
Posts: 10749
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

Thank you very much for the nice review! We really appreciate it.


Posts: 96
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
(@deepline-digital)
Estimable Member
Joined: 6 years ago

Hello,

How do I find topic id and forum id?
 
Thank you

 


1 Reply
Alvina
Moderator
(@alvina)
Joined: 7 years ago

Member
Posts: 1857
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

@t-niron,

You just need to hover in the "RSS" button to see the forum and topic ID's, see the screenshot below: 


Share: