Notifications
Clear all

Script [Solved] Sidebar left on mobile

7 Posts
6 Users
2 Likes
979 Views
Posts: 1133
Topic starter
(@percysgrowroom)
Noble Member
Joined: 5 years ago

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?

6 Replies
Robert
Posts: 10499
Admin
(@robert)
Support Team
Joined: 8 years 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: 5 years ago

Noble Member
Posts: 1133

@robert just so youll know, this plug in is no longer available because of a security issue

Chris
(@chris)
Joined: 3 years ago

Famed Member
Posts: 3650

@percysgrowroom,

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

(@mtumbady)
Joined: 10 months ago

Active Member
Posts: 10

@robert This plugin is not available any other plugin for make recent post in page

(@bizsgen)
Joined: 4 months ago

New Member
Posts: 1

@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: 495
(@verek)
Honorable Member
Joined: 6 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.