Looper: show recent post from a specific post category

Hi Oli,

You can create an Archive Layout just like what you have in the screenshot. please go through the following thread with a similar topic.

Hope it helps.
Thanks

1 Like

thanks for the tipp.
strangly the row with the condition ODD is not displaying. any idea?

live: https://www.amanox.ch/de/_tmp_blog/

oli

Hi Oli,

I have checked the given page URL and found that the condition for the Even index is set to the Looper Provider section itself and that is why it only shows the Even rows. I went ahead and removed that condition and now the Layout is showing as expected.

Thanks

1 Like

ah, i see! thanks! very great!!! oli

Hello Oli,

Glad that we were able to help you. Please feel free to reach us if you have any more query concerns.

Thanks

1 Like

hello,

there are additonally two things:

  1. i have an article and i am showing the other other articles via a looper.
    how can i hide the article the user is actually in?

  2. plus under some browser width: how can i hide the next – only partly visible article?

live:
https://www.amanox.ch/de/machine-learning-in-der-praxis/

thanks
oli

Hi Oli,

We are not sure what exactly you try to mean in the first point. In the second point, you may need to adjust the container width for the specific screen size where you are having this problem.

Hope it helps.
Thanks

hello,

1. not showing the current post in the more posts slider.

the goal is not to show the current in the more post slider, as the user is already on the post
and i want to show only the other posts (so hide of the current post) – i hope it is clearer.

e.g. if i am here https://www.amanox.ch/de/weareamanox-fabio-calcio-gandino/
(article about fabio), i do not wish to see it in the more posts.

2. cut of next slider

it is on all screen sizes – i was not very precise

i want that the sider content is in the content width, but i do not want to show only parts.

at the moment i have the content sizing checked to global container in the slider container,

if i do this on another elements there is the same effect (cut of the next slider).

cheers!
oli

Hello @oblaum,

1.) To get this resolve, please follow the solution given by @Kory in this old thread:

2.) You need to set the sizing of the Row 2 to use the Global Container.

Simply Click the Row 2 element and inspect to find the Size option:

You need to disable the Global Container of the Slide Container element:

And then adjust the Left/Right margins of the Prev/Next button:

Kindly let us know how it goes.

1 Like

hello @ruenel,

great. this worked out very very well.

i want to show in a looper events in order of the date.
as the events are in the future i have create a start and end date in ACF.
(jquery date field in the format d/m/Y e.g. 14/01/2022)

  1. sort all dates from ACF start date (field “start_datum”) ascending

  2. do not show or better do not load events which are in the past ACF end date (field “datum_ende")

events could be going over several days or just one. therefore start/end date.
category is event.

live:
https://www.amanox.ch/de/_tmp_blog/


thanks
oli

Hello Oli,

You are using the Looper Provider Query Builder:

This looper do not have the ability to select and sort items with custom meta or the ACF field. You will have to use the Looper Provider Query String instead. Kindly check out this old thread as a reference:

And since you are using the posts labeled as events category, you will need to change the mec-events to post instead.

Kindly let us know how it goes.

1 Like

hello @ruenel,

i have trieds so. in bold the changes i have made.

in the code snippet (for the function)

$meta_query[] = array(
‘key’ => ‘start_datum’,
‘value’ => date(‘Ymd’),
‘compare’ => ‘>=’,
‘type’ => ‘DATE’
);

$tax_query[] = array(
‘taxonomy’ => ‘category’,
‘terms’ => ‘event’,
);

$query = array(
‘post_type’ => ‘post’,
‘posts_per_page’ => 20,
‘tax_query’ => $tax_query,
‘meta_key’ => ‘start_datum’,
‘orderby’ => ‘meta_value’,
‘order’ => ‘ASC’,
‘meta_query’ => $meta_query
);
var_dump( http_build_query( $query ) );

and in the looper provider as query string:

post_type=post&posts_per_page=20&tax_query%5B0%5D%5Btaxonomy%5D=category&tax_query%5B0%5D%5Bterms%5D=event&meta_key=start_datum&orderby=meta_value&order=ASC&meta_query%5B0%5D%5Bkey%5D=start_datum*

when doing so it shows the latest post, but not the articles in the category event and it seems not to take account of the ACF field ‘start_datum’.

live:
https://www.amanox.ch/de/_tmp_blog/

(on the bottom of the page how it should look like)

thanks
oli

Hi Oli,

Please remove the Tax_Query(). Use only the meta query:

$meta_query[] = array(
	'key' => 'start_datum',
	'value' => date('Ymd'),
	'compare' => '>=',
	'type' => 'DATE'
);

$query = array(
	'post_type' => 'post',
	'posts_per_page' => 20,
	'category_name' => 'event',
	'meta_key' => 'start_datum',
	'orderby' => 'meta_value',
	'order' => 'ASC',
	'meta_query' => $meta_query
);
var_dump( http_build_query( $query ) );

Kindly let us know how it goes.

1 Like

hello @ruenel,

thanks – i adjust the looper as well:

post_type=post&category_name=event&posts_per_page=20&offset=0&orderby=meta_value&order=ASC&meta_query%5B0%5D%5Bkey%5D=start_datum

now it works great. but i want that old events are not displayed.

i have put in the first (‘märz’) event in ACF ‘start_datum’ field the date 20220115 (yesterday) but the post still shows up. great would be to use the ACF ‘datum_ende’ (end date) field as events could be one day or serveral days.

how to solve this?

thanks
oli

Hello Oli,

Please check out this old thread. You can refer to this and base your query string on this thread:

Best Regards.

1 Like

hello @ruenel,

great. i was managed to solve this. thank you very much.

post_type=post&category_name=event&posts_per_page=20&meta_key=start_datum&orderby=meta_value&order=ASC&meta_query%5B0%5D%5Bkey%5D=start_datum&meta_query%5B0%5D%5Bvalue%5D={{dc:global:date format=“Ymd”}}&meta_query%5B0%5D%5Bcompare%5D=%3E%3D&order=ASC

the very last thing i need to know is:
i want to display in a seperate page only all the old events. how can i reach this?

thanks
oli

Hi Oli,

Glad that we are able to help you. To get the older posts, you can add the similar Query String with the specific date and compare it with the less than clause. Or you can use the between in comparison to getting the posts between specific two dates. I would suggest you go through the following article on the meta queries using the compare.

https://rudrastyh.com/wordpress/meta_query.html
https://diveinwp.com/meta_query-to-compare-between-dates-in-wordpress/

Hope it helps.
Thanks

1 Like

thank you @tristup. i will have a look into the urls…

Hi Oli,

You are most welcome. Hope the links will help you.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.