Posted 03 December 2012 - 01:39 PM
I would like to do a custom query. I have added a custom query in the postloop section (which I copy-pasted in a child theme):
It is working. However, pagination is not working properly. I understand from different forums that I should use wp_query. My question is how I can use wp_query within Pagelines. I have tried:
but I don't know how I can execute this new query in Pagelines.
Posted 03 December 2012 - 03:10 PM
I am not sure, but I think I cannot use this filter as I want to make a frontend filter for users (i.e. a buttons to sort by rating, date etc). Or is it possible to execute the filter only after a button is submitted?
Posted 03 December 2012 - 03:46 PM
You don't need a filter. Paged results is kind of a bitch to get working correctly within PageLines. There's a default section called Pagination that will work with your query in your section. Just drag the Post/Page Pagination section below your new section.
Posted 03 December 2012 - 04:20 PM
I already was using the Post/Page Pagination section below the new section, hence that's not it.
I understand the pre_get_posts filter is the best solution as it runs (as it's name suggest) before the first query and prevents unnecessary requests, but I don't know how to execute it out of a form action. Any ideas?
An alternative could be to use wp_query. Any ideas how I can use a custom wp_query within Pagelines?
Posted 03 December 2012 - 06:30 PM
I just went through all of this as I wrote AnyLoop, a custom post loop section on the store. It has multiple wp_queries and can run simultaneously. And after much frustration, using the section I described works, with wp_query. Feel feel to experiment on your own, I'm just trying to save you some time.
Posted 03 December 2012 - 06:52 PM
That is very much appreciated.
How can I execute a wp_query in Pagelines?
Posted 03 December 2012 - 08:20 PM
Just create your own section using the Base Section (known as the free Pull Quote example section in wp admin store), drop in the query, and fashion the output how you please. Then just drop the section on whatever you page you want.
Posted 04 December 2012 - 07:45 AM
Do you mean I have to build and style my own loop? I was hoping I could create a custom wp_query and use the Pagelines loop. Is that possible?
Posted 04 December 2012 - 08:35 AM
PHP at the moment is my forte but this topic should help you.
Posted 04 December 2012 - 12:25 PM
Thanks. I see I was struggeling with this already in december :-)
I have this working with post_query. Created a custom section in the base child theme. This works:
I can change the array of the query_post to get any custom loop I would like. However, using query_posts gives trouble with the pagination. I read on a couple of forums that I should use wp_query. Let's say I would like to query only cat 3. Wordpress codex shows this code:
Adding this in a custom section also works great. It creates a list of category 3 post titles. Instead of this simple loop I would like to load the Pagelines loop. How can I do that? I tried
but that didn't work.
Posted 04 December 2012 - 12:48 PM
Hmm, it would appear that the code on the link I gave you has been stripped, let me find this out for you.
Posted 05 December 2012 - 08:48 AM
I cannot imagine this is hard for a pagelines developer Pretty basic customization stuff I would say. It would be very much appreciated if someone could give an example of how I can do a custom wp_query in Pagelines while using the Pagelines loop.
Posted 05 December 2012 - 02:30 PM
That adds your rating, but you need to add a check in there for 'if a button is pressed'
Posted 06 December 2012 - 09:46 AM
Thank you for your time!. Actually I already had the filter working. What I am trying to accomplish is a couple of buttons wihch users can click to sort the posts (based on rating, views and date). I would like to have the filter buttons above all loops and behave dynamic. Hence, when a user is on a category/taconomy/tag page it will filter the posts within that taxonomy. My guess was that I should use a custom wp_query instead of the pre_get_post filter to allow dynamic behaviour? That is why I was looking for an example of a wp_query instead of query_posts within pagelines?
In the meantime I could show the buttons only for the mainloop on the homepage. The code below works, but not with pagination... :-) Maybe because the pre_get_posts filter gets the $filter variable to late or something?
Posted 06 December 2012 - 10:57 AM
Posted 06 December 2012 - 11:00 AM Best Answer
Well. The above code does work (incl. pagination) with the GET method! Are there any security issues with using GET? I guess it is fine to use for a filter?