Filter settings

Posted in: Newspaper
Post count: 7

How can I set the filter settings so that only posts from 2024 and 2025 are displayed? I use Flex Block 2, the largest window on the website. In this time frame, the ads should be displayed in mode: Random. Is that possible? See also attachment. KI gives me an individual php code for this: But I don’t know where I could insert it? I don’t know if it works?

function beitraege_2024_2025_random() {
$query = new WP_Query([
‘post_type’ => ‘post’,
‘orderby’ => ‘rand’,
‘posts_per_page’ => 5,
‘date_query’ => [
[
‘after’ => ‘2023-12-31’,
‘before’ => ‘2026-01-01’,
‘inclusive’ => true,
]
]
]);

ob_start();
if ($query->have_posts()) {
echo ‘

‘;
wp_reset_postdata();
}
return ob_get_clean();
}
add_shortcode(‘artikel_2024_2025’, ‘beitraege_2024_2025_random’);

Thank you very much for your help.

See also this link:

https://ibb.co/tMkRWSxK

This is the Website: https://e-m-l.ch

Raphael Gasser

Post count: 35449

Hi,
Most of the time shortcode are se in functions.php and it can be set in functions.php in a child theme, but I can not say if this will work or not or how to adjust the code. Unfortunately for this you’ll need a developer to help you with the code and create a new filter.
Also, the ads if are adsense ads will be display bas on users search on google.
Thank you!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.