Combine Events, by publish date, in mutli CPT query

Home Forums Calendar Products Events Calendar PRO Combine Events, by publish date, in mutli CPT query

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1001572
    Graham Stacey
    Participant

    Hi,

    I have looked at a few thread that deal with ordering events by published date and your KB post on ordering by publish date in the main blog.

    We have an query that currently combines 4 CPTs, including events, but the future dated events hog the top spots when displayed. We need to query the events by published date, which we can then use to manually manipulate the position of the Event within the resulting query.

    Here is a link to the current production site

    https://womenandthechurch.org

    Here is a link to the gist

    https://gist.github.com/OandB/bc2920b6f4e575b616b9

    And if that does not work then…

    <?php $the_query = new WP_Query( array(
    					'offset' => 1,
    					'posts_per_page' => 6,	
    					'post_type' => array( 'tribe_events', 'news', 'feature', 'resources' )
    					) ); ?>
    <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

    Thanks
    G

    • This topic was modified 10 years, 7 months ago by Graham Stacey.
    • This topic was modified 10 years, 7 months ago by Graham Stacey.
    #1001731
    George
    Participant

    Hey Graham,

    I’m sorry you’re having trouble here! Just to put the disclaimer out early, we cannot help with custom code and such, so you’ll mostly have to take the reins on this one.

    With that out of the way, I’m happy to at least try and help as much as possible within reasonable scope of our forums here.

    I’m wondering what you find if you try simply adding the WP_Query ‘orderby’ parameter, then specify something like ‘modified’ etc.

    Have you tried this? So, for example, something like this:


    $the_query = new WP_Query( array(
    'offset' => 1,
    'posts_per_page' => 6,
    'post_type' => array( 'tribe_events', 'news', 'feature', 'resources' ),
    'orderby' => 'modified'
    ) );

    What happens if you try that out?

    #1002036
    Graham Stacey
    Participant

    Thanks George for this.

    This led me to look at the orderby spec a little closer.
    I am not sure this will work for us as we are then juggling modify posts to try and get them in the order we would like on the homepage.

    We have had a go at implementing this:

    Order Events by Post Date in the Main WordPress Post Query

    For the time being and seeing how that goes. We can then use the publish date to affect the order on the home page. Thankfully this does not seem to affect the order of events on the main events listing.

    Thanks for your help
    G

    • This reply was modified 10 years, 7 months ago by Graham Stacey.
    #1002891
    George
    Participant

    Hey Graham – I’m sorry you have to go to such lengths to achieve the effect you want, at this time, but am glad that there is some semblance of a “solution” (or at least a “workaround”) for now.

    I hope that works well on your site – stay tuned to plugin updates over time because querying for events is a weak point of our plugin that we hopefully can improve. If you have any specific ideas regarding how to do this, we’d love for your feedback on our UserVoice page here → http://tribe.uservoice.com/forums/195723-feature-ideas

    I’ll close up this thread for now, but if you’d like help with anything else come back and open a new thread any time 🙂

    Best of luck with your site,
    George

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Combine Events, by publish date, in mutli CPT query’ is closed to new replies.