Archived topic
Changing location of recent posts in mobile view
5 replies · Started by Devesh on June 19, 2019
How can i change the layout for mobile view.
For e.g. I want to make the comments box appear below the recent posts (since recent posts get pushed to the bottom of the post in the mobile view and not on the sidebar as in desktop view)
Hi there,
couple of ways to do this, one would require a child theme and editing of the single-post templates to change the comments form position.... tricky.
The alternative is to install the Widget Shortcodes plugin:
https://en-gb.wordpress.org/plugins/widget-shortcode/
Then with the shortcode it generates for the related posts you can hook that in to position using a Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
1. Create a new Hook
2. Add the following code:
<div class="hide-on-desktop">
// Add the shortcode here //
</div>
3. Select the before_comments_container hook
4. Check the Execute Shortcodes checkbox
5. Set the Display rules to Posts > All Posts
6. Add this CSS to remove the Right Sidebar on mobile:
@media (max-width: 768px) {
#right-sidebar {
display: none;
}
}
Cool solution....it worked.
Just wanted to know adding this plugin and hook.....i hope it does not reduce the site speed?
Awesome :) Saved rewriting templates...
It shouldn't make any noticeable difference using a single shortcode to display the content.
Many Thanks!
You're welcome