Hi there,
I found out that the query of the post loop widget in the siteorigin page builder does not take into consideration the posts_per_page and offset vars if you select the only sticky posts or exclude sticky posts from the UI.
This tested with Unwind theme (free).
Regards,
George
Hi George,
Can you please elaborate on the issue you’re facing? I’ve run some tests and the Posts Per Page setting and additional offset value is working as expected for me. while using SiteOrigin Unwind and Twenty-Twenty. Please note that the Posts Per Page setting is recommended over the adding posts_per_page to the additional field.
For reference, here’s what each of the Sticky Posts options does:
Default – Sticky posts are appended to search results and offset isn’t applied to Sticky Posts. This is the WordPress default.
Ignore sticky – Don’t move the sticky posts to the front of the results, but will still allow for them to appear.
Exclude – Exclude all sticky posts from post loop.
Only Sticky – Only display sticky posts.
Kind regards,
Alex
Hi Alex,
I tried to use the Posts Per Page setting in the first place together with the Only Sticky setting and this is not working. All the above are tested in a new clean WP installation using the Unwind theme and the siteorigin Page builder plugin with the post loop widget. Inside post loop I have used the post slider template with Only sticky and another post loop with the Blog grid template.
George
Hi George,
I’m having trouble replicating this result. Can you please clarify what value you set Posts Per Page to? Ideally, can you please provide me with a screenshot of your settings? You can upload the screenshot to Imgur or vgy.me. WordPress is designed to disregard the offset if the Posts Per Page setting is set to -1. There are also other situations where WordPress will intentionally disregard your selections if other settings prevent them from working as intended – these limitations typically can’t be avoided. Inspecting your adjusted setting values will allow me to identify if the results you’re getting are expected.
Kind regards,
Alex
Hi Alex,
I set Posts Per Page to be 1 and I check the Only Sticky option. Please find screenshot with settings and the posts I use.
https://i.vgy.me/VDSt8Z.png
https://i.vgy.me/UT3ljn.png
Waiting for you reply.
Regards,
George
I have tested the
after
has run inside inc/widgets/post-loop.php of the panels plugin and I get the following query:
SELECT SQL_CALC_FOUND_ROWS testwp_posts.ID
FROM testwp_posts
WHERE 1 = 1
AND testwp_posts.ID IN (8, 10)
AND testwp_posts.post_type = ‘post’
AND (testwp_posts.post_status = ‘publish’ OR testwp_posts.post_status = ‘private’)
ORDER BY testwp_posts.post_date DESC
LIMIT 0, 1
and this is correct as the SQL gives only 1 result.
I still cannont find who mess with query after that.
Hi Gkorakas,
Thank you for the screenshot of your settings and posts. Does the expected number of replies show if you use a different template?
Kind regards,
Alex
Hi Alex,
The same happens with all the templates. Can you replicate the issue or it is working fine on your end?
Regards,
George
Hi George,
Yes. When I use the Post Loop widget using your settings and SiteOrigin Unwind, it works as expected – a single post per page and only the sticky posts. If I set an offset, the first sticky item is skipped over. If that’s the result you’re getting, but that’s undesired, can you please elaborate on your desired result?
If you’re not getting that result, and that’s what you would like to see, can you try disabling all non-SiteOrigin plugins and see if this fixes the issue? You’ll need to clear all your caches after disabling your plugins.
If it does fix the issue, then try re-enabling your plugins one by one until the issue comes back. This procedure will help diagnose which plugin is causing the issue.
Once we know that, we’ll be able to look at what might be causing the conflict and either solve the problem or help you find an alternative plugin.
Kind regards,
Alex
Hi Alex,
I am not using any other plugins. I am testing on a new clean WP installation with Unwind theme and site origin page builder plugin.
I will dubug this further and I will come back to you.
Regards,
George
Can I use pre_get_posts hook to change the query for a specific page builder widget in a page? Can I determine which query has to do with a specific widget?
I am trying to build a page that will show only sticky posts but with a limit (like 10 posts) so as the sticky posts inscrease in the site the page will always show the last 10 sticky posts.
Regards,
George
Hi Gkorakas,
In theory, yes.a
You’ll need to pass an additional parameter to identify the post loop – for example, add test=123 and then check for the test additional parameter.
Ah. Thank you for clarifying. All (bar the Slider) Unwind post loops templates are designed to allow for pagination so upon posts_per_page amount is reached, a new page will be linked. There’s no direct way to disable the pagination, but you could hide the pagination using CSS.
Kind regards,
Alex
Hi Alex,
I am afraid that the paginations is not working with sticky posts.
Regards,
George
Something is messing with the query sto the following code does not work either.
Please also look into the following. The post__in is indeed an array of 5. This should be enough to limit the WP query.
Hi Gkorakas,
The provided PHP requires the additional field to be set to test123=1. Upon setting the additional field to that the provided PHP is working as expected for me. I tested this by adding the provided snippet using the Code Snippets plugin.
Kind regards,
Alex