AI Assistant
Notifications
Clear all

[Solved] Sidebar left on mobile

7 Posts
6 Users
2 Reactions
2,643 Views
Posts: 1242
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
(@percysgrowroom)
Noble Member
Joined: 7 years ago
[#19383]

I have asked this before and cant find the thread..... But on mobile, I would like the side bar to show before the main forum. So my recent posts.Β 

I would be good if i could just add one widget like "recent post" on top of the forum on mobile. So the members can see recent posts and not the whole side bar. It is a pain to scroll passed the whole forum to get to the widgets....

Β 

Any idea how to fix this?

The page I need help with

6 Replies
Robert
Posts: 10719
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: 2 months ago

Hi @percysgrowroom,

I think you should use this plugin, put the widget before the [wpforo] shortcode in the forum page editor:

https://wordpress.org/plugins/amr-shortcode-any-widget/

You should contact this plugin developers and ask them to help you to only show this widget on mobile pages.

Β 

Or you can put this code into the functions.php of your current active WordPress theme. This will add new sidebar in Dashboard > Appearance > Widgets admin page, so the widgets in this sidebar will be only displayed on the forum top area on mobile devices:

function wpforo_custom_sidebar() {
register_sidebar( array(
'name' => __( 'Forum Top Mobile Sidebar', 'textdomain' ),
'id' => 'mobile-sidebar',
'description' => __( 'Widgets in this area will be shown on forum top for mobile only.', 'wpforo' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'wpforo_custom_sidebar' );


function wpforo_custom_sidebar_area() {
if( function_exists('is_wpforo_page') && is_wpforo_page() ){
if ( !is_active_sidebar( 'mobile-sidebar' ) || !wp_is_mobile() ) return;
echo '<div class="wpforo-top-sidebar">';
dynamic_sidebar( 'mobile-sidebar' );
echo '</div>';
}
}
add_action( 'wpforo_top_hook', 'wpforo_custom_sidebar_area' );

BTW, you can use Code Snippets plugin to add custom codes.


4 Replies
(@percysgrowroom)
Joined: 7 years ago

Noble Member
Posts: 1242
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 just so youll know, this plug in is no longer available because of a security issue


Chris
(@chris)
Joined: 5 years ago

Famed Member
Posts: 3610
Robert
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

@percysgrowroom,

Just checked, it's available and got a new update 3 days ago.


(@mtumbady)
Joined: 3 years ago

Eminent Member
Posts: 13
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 This plugin is not available any other plugin for make recent post in page


(@bizsgen)
Joined: 2 years ago

Active Member
Posts: 3
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 the code is perfect. Can you let me know how to show this below wpforo menu. Right now the widget shows above the forum menu. And also, I want to show this only on home page on mobile.


VereK
Posts: 522
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
(@verek)
Honorable Member
Joined: 8 years ago

This is fantastic @robert. Only small change I would make is H2 class the same as the normal sidebars (widget-title) so that any styling css that we may have done is uniform.


Share: