Support

Account

Forum Replies Created

  • I have Field Group “nimipäivät” (namedays)

    Inside that I have 2 fields

    “nimi” (name) = text
    “päivämäärä” (date) = date picker
    IMAGE:https://ibb.co/Gx8Z7YS

    Also I have Custom post plugin and there is added namedays
    IMAGE: https://ibb.co/6X79X4F

    Group fields post rule is set to nimipäivät IMAGE:https://ibb.co/Gx8Z7YS

    Now I would need to show todays date posts ONLY on my homepage.

    I have this code added to my funtions.php

    function show_todays_name_days() {
    // Hae tämän päivän päivämäärä
    $today = date(‘Ymd’); // Muutettu takaisin Ymd-muotoon

    // Luo uusi WP_Query-objekti
    $args = array(
    ‘post_type’ => ‘nimipaivat’,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘field_65236d64b874e’, // Päivitä tämä kentän avaimellasi
    ‘value’ => $today,
    ‘compare’ => ‘=’
    )
    )
    );

    $query = new WP_Query($args);

    // Tarkista, onko postauksia
    if ($query->have_posts()) {
    while ($query->have_posts()) {
    $query->the_post();
    // Tulosta postauksen otsikko ja sisältö
    echo ‘<h2>’ . get_the_title() . ‘</h2>’;
    echo ‘<div>’ . get_the_content() . ‘</div>’;
    }
    } else {
    // Ei postauksia tälle päivälle
    echo ‘Ei nimipäiviä tänään.’;
    }

    // Palauta alkuperäinen postausdata
    wp_reset_postdata();
    }

    add_shortcode(‘show_todays_name_days’, ‘show_todays_name_days’);

    And I am using this shortcode : [show_todays_name_days]

    But this code doesnt work and I dont know how to show todays date posts on my homepage.

    Using also Elementor with Hello theme

  • I have Field Group “nimipäivät” (namedays)

    Inside that I have 2 fields

    “nimi” (name) = text
    “päivämäärä” (date) = date picker
    IMAGE:https://ibb.co/Gx8Z7YS

    Also I have Custom post plugin and there is added namedays
    IMAGE: https://ibb.co/6X79X4F

    Group fields post rule is set to nimipäivät IMAGE:https://ibb.co/Gx8Z7YS

    Now I would need to show todays date posts ONLY on my homepage.

    I have this code added to my funtions.php

    function show_todays_name_days() {
    // Hae tämän päivän päivämäärä
    $today = date(‘Ymd’); // Muutettu takaisin Ymd-muotoon

    // Luo uusi WP_Query-objekti
    $args = array(
    ‘post_type’ => ‘nimipaivat’,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘field_65236d64b874e’, // Päivitä tämä kentän avaimellasi
    ‘value’ => $today,
    ‘compare’ => ‘=’
    )
    )
    );

    $query = new WP_Query($args);

    // Tarkista, onko postauksia
    if ($query->have_posts()) {
    while ($query->have_posts()) {
    $query->the_post();
    // Tulosta postauksen otsikko ja sisältö
    echo ‘<h2>’ . get_the_title() . ‘</h2>’;
    echo ‘<div>’ . get_the_content() . ‘</div>’;
    }
    } else {
    // Ei postauksia tälle päivälle
    echo ‘Ei nimipäiviä tänään.’;
    }

    // Palauta alkuperäinen postausdata
    wp_reset_postdata();
    }

    add_shortcode(‘show_todays_name_days’, ‘show_todays_name_days’);

    And I am using this shortcode : [show_todays_name_days]

    But this code doesnt work and I dont know how to show todays date posts on my homepage.

    Using also Elementor, Hello theme

  • Hey!

    I have deleted all as what I tryed didnt work so there no fields rn.

    So my issue is how to get data if I create Field Group Labels:

    Field Group: Namedays

    Labels:
    Date (date picker)
    Name (text)

    With these I can create a nameday post.

    Now on my homepage, I would need to get data from that “Date” so that it shows only the posts that have todays date on it. By that way the post (someones dayname) appears on my homepage.

    How to do this? If this makes sense to you, please let me know step by step guide as I havent used ACF before.

    Note: I use Elementor, and If I now set Elementor widget to show “nameday” posts, it will show all of them. It should only show the posts that has todays date on them.

Viewing 3 posts - 1 through 3 (of 3 total)