Looper: show recent post from a specific post category

hello,

i want to show the last three posts from a specific category (=news)
via looper. i need to get this fields information:

wordpress fields:
. features image
. text except
. author name
. link to post

acf pro custom fields:
. artikel-subline
. artikel-headline

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

how to?

thanks
oli

Hello Oli,

Thanks for writing to us.

To display the post from a specific category you need to set the Looper Provider as Query String and then you need to set the category from the Taxonomies select box.
tedt-Page-Builder-X (3)

You use the dynamic content code to display the ACF field and Post details.

tedt-Page-Builder-X (4)

In case if you have not seen the ACF field doc please have a look at it to learn more about how to pull data from the dynamic content code.

Hope it helps
Thanks

1 Like

hello prakash_s,

thank you, i was manage to do so.

i have on another page a layout where there is a layout variation.
image right, image left and then image left again.

how can i manage this? e.g. if i can get the information for the last post, the post before, and the the post before – each as a single looper (only for category news)

how to solve this?


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

thanks
oli

Hi Oli,

Not sure what exactly you are trying to achieve. Can you please elaborate a bit more?

Thanks

hello,

i want to show the 3 latest post from the category “knowledgesharing” –
but i want the rows to be not look the same. there should be the variation:

1st row image on the right
2st row image on the left
3st row image on the right (again)
(see screenshot)

when i use the query builder it displays all the row in the same layout –
so the idea was to have three loopers (1st ask for the latest post information, 2st ask for the post information and 3st ask for the post before that) – how can i do this or is there a much better way to solve it?

see simulation:

thanks
oli

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