Support » Plugin: ACF Recent Posts Widget » Hook to show future posts

  • Resolved franklin82

    (@franklin82)


    I’m using this to show upcoming events in the sidebar which is working nicely but if I change the order from DSC to ASC I get all my old events showing.

    Is there a way to say only show the next 5 events in ASC order greater than today’s date?

    Thanks!

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author Rafał Gicgier

    (@gicolek)

    Hey @franklin82,

    Yes, the behavior is expected. At first glance I would have to apply some code changes to give you such an ability.

    I will have to think of the solution so I can’t help you right away – probably this will take longer than a week due to my holiday this week.

    Anyway perhaps you could temporarily add some posts to a tag / category? This would limit the number of posts being displayed within the widget to only those from the asssigned.

    Is there a way to say only show the next 5 events in ASC order greater than today’s date?

    May you please rephrase that?

    Regards,
    Rafal

    Thread Starter franklin82

    (@franklin82)

    Hi @gicolek,

    What i’m looking to do is show any post based on my custom field ‘event-date’ and if the date is greater than todays date shows them in ASC order.

    Hope that makes more sense.

    Thanks!
    Michael

    Plugin Author Rafał Gicgier

    (@gicolek)

    Hey @franklin82,

    Does this part of the documentation help you out:

    The Meta Value field supports an array of elements, so that all of the meta_compare parameters could be used. To do so, please specify the two parameters separated by semicolon, for instance: 1234;12345.
    The plugin will convert these into an array and apply the proper operation for the two. Whatsmore the [date] shortcode can be used here. It takes the timestamp paramater as an argument, which is required – the possible arguments are the same as for
    the function described here: http://php.net/manual/pl/function.strtotime.php. For instance [date +1 day] would generate the tomorrow date in “Ymd” format.
    This can be used with custom meta field date.

    I’ll do my best to reply ASAP, but can’t promise anything now.

    Regards,
    Rafal

    Thread Starter franklin82

    (@franklin82)

    @gicolek,

    It has helped but but it’s just the order of those posts now, not sure how would be best to do it.

    No rush on this, this would be the icing on the cake 🙂

    Plugin Author Rafał Gicgier

    (@gicolek)

    Hello again @franklin82,

    My apologies for such a huge delay!

    May you please provide with screenshots of your setup?

    Please include the following:

    1. ACF Custom Fields Setup.
    2. Widget / Shortcode setup with the values you have specified.
    3. A sample future post setup.

    I’d like to recreate that directly within my environment to make sure we’re on the same plate here.

    Sincerely,
    Rafał

    Thread Starter franklin82

    (@franklin82)

    Hi @gicolek,

    No problems – thanks for coming back to me, screenshots of the setup for you.

    1. ACF Custom Fields Setup
    2. Widget
    3. sample future post setup

    I did also change the acfrpw/loop-inner.php (line 61) to the below to include the event-date field.

    <?php endif; ?>
    	<a href="<?php the_permalink(); ?>" rel="bookmark">
    	<span class="date meta-item"><?php the_field( 'event-date' ); ?></span>
    	<h3 class="acf-rpw-title"><?php get_the_title() ? the_title() : the_ID(); ?></h3></a>

    Let me know if you need anything else.

    Thanks!

    Plugin Author Rafał Gicgier

    (@gicolek)

    Hey @franklin82,

    Thanks! I’ll recreate that setup. Can you also share a screenshot of the Event Date field setup? There are some settings that may affect the problem you’re dealing with.

    Outside of that I don’t need anything else!

    Sincerely,
    Rafał

    Thread Starter franklin82

    (@franklin82)

    Hi @gicolek,

    That should be in the first link included above or do you mean from somewhere else?

    Thanks,
    Michael

    Plugin Author Rafał Gicgier

    (@gicolek)

    Hi @franklin82,

    Right, but I would like to see the field “open” to see the settings of the date field 🙂

    Can you make sure it’s toggled on?

    Sincerely,
    Rafal

    Thread Starter franklin82

    (@franklin82)

    @gicolek gotcha,

    Here you go: https://ibb.co/G038csC

    Michael

    Plugin Author Rafał Gicgier

    (@gicolek)

    Thanks @franklin82,

    That’s exactly it 🙂

    I’ll get back to to you tomorrow tops.

    Thanks for the patience.

    Regards,
    Rafal

    Plugin Author Rafał Gicgier

    (@gicolek)

    Hello @franklin82,

    Here’s the solution:

    1. Widget setup: https://www.screencast.com/t/RpA8IF8kwN6Q (note you can’t use acf meta key within the Meta Value field – it accepts the date only :))
    2. ACF field setup: https://www.screencast.com/t/fXZHfYEpGLo

    Locally, on Vanilla it gives correct results, not listing older posts: https://www.screencast.com/t/xcDWkFha5

    Let me know if that works for you!

    Cheers,
    Rafal

    Thread Starter franklin82

    (@franklin82)

    Hey @gicolek thanks for that, I’ll give a go.

    Do I need to need that code in shown on the last image anywhere, if so where should that be?

    Thanks!
    Michael

    Plugin Author Rafał Gicgier

    (@gicolek)

    Hello @franklin82,

    No, you don’t – it’s just a debug info that can be ignored. Sorry if that caused some confusion.

    Sincerely,
    Rafał

    Thread Starter franklin82

    (@franklin82)

    Hey @gicolek,

    Does the ACF field output need to be in ‘Ymd’ format or can this be changed to ‘F j, Y’. In the test you’ve done the date is showing correctly but for me it displays a date like ‘20190523’ which isn’t very friendly.

    Thanks

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Hook to show future posts’ is closed to new replies.