Support

Account

Forum Replies Created

  • Hi again,

    I’ve tested something and it work : I re-save the group field under ACF menu and everything return to normal.

    My futur and past events are back.
    Hope this can help anyone.

  • Hi,

    I was on my way to write a new post on the forum when I read this one. So I post here, hope this is relevant.

    The code below was working like a charm, and it doesn’t since last wp update (Wp 5.1.1) with ACF 5.7.13.

    Basically I call my custom post type ‘event’ twice. One time for the futur events, one time for the past event.

    Since WP update, the futur event doesn’t display.

    The initial code

    
    $today = date("Ymd");
    
    // Futur event (works before update)
    $nextevents_args = array(
        'post_type' 	=> 'event', 
        'post_status' 	=> 'publish',
        'meta_query'	=> array(
            array(
                "key" => "date",
                "value" => $today,
                "compare" => ">"
            )
        ),
        'posts_per_page' => -1,
        'orderby'  => 'meta_value_num',
        'meta_key' => 'date',
        'order'    => 'ASC',
    );
    $nextevents = new WP_Query( $nextevents_args );
    if ($nextevents->have_posts()):
        while ($nextevents->have_posts()) :
           $nextevents->the_post();
           the_title();
        endwhile; 
    endif;
    wp_reset_postdata(); 
    
    // Past events
    $oldevents_args = array(
        'post_type' 	=> 'event', 
        'post_status' 	=> 'publish',
        'meta_query'	=> array(
            array(
                "key" => "date",
                "value" => $today,
                "compare" => "<"
            )
        ),
        'posts_per_page' => -1,
        'orderby'  => 'meta_value_num',
        'meta_key' => 'date',
        'order'    => 'DESC',
    );
    $oldevents = new WP_Query($oldevents_args);
    if ($oldevents->have_posts() ):
       while ($oldevents->have_posts() ) :
            $oldevents->the_post();
            the_title();
       endwhile; 
    endif;
    wp_reset_postdata(); 

    In this example, the past events are displayed, the futur events are not.

    I’ve tested

    var_dump($today) // return '20190419'

    Where I’m loosing my hair :
    1) The two queries are exactly the same, only the “compare” argument is different.
    2) In the “futur event” query, if I replace

    
    "key" => "date",
    "value" => $today,
    "compare" => ">"
    

    by

    
    "key" => "date",
    "value" => '20190419',
    "compare" => ">"
    

    It works !!

    Also :
    – I’ve set up a new event today (in wp 5.1.1 / acf 5.7.13), I check and the field date is saved into the DB
    – I change the type of $today into ‘integrer’ but that doesn’t change anything. The futur event are still not showing.

    Hope someone can help,
    Thank you

    PS : sorry if I’m not on the right forum post.

  • Hi,

    I was on my way to write a new post on the forum when I read this one. So I post here, hope this is relevant.

    The code below was working like a charm, and it doesn’t since last wp update (Wp 5.1.1) with ACF 5.7.13.

    Basically I call my custom post type ‘event’ twice. One time for the futur events, one time for the past event.

    Since WP update, the futur event doesn’t display.

    The initial code

    
    $today = date("Ymd");
    
    // Futur event (works before update)
    $nextevents_args = array(
        'post_type' 	=> 'event', 
        'post_status' 	=> 'publish',
        'meta_query'	=> array(
            array(
                "key" => "date",
                "value" => $today,
                "compare" => ">"
            )
        ),
        'posts_per_page' => -1,
        'orderby'  => 'meta_value_num',
        'meta_key' => 'date',
        'order'    => 'ASC',
    );
    $nextevents = new WP_Query( $nextevents_args );
    if ($nextevents->have_posts()):
        while ($nextevents->have_posts()) :
           $nextevents->the_post();
           the_title();
        endwhile; 
    endif;
    wp_reset_postdata(); 
    
    // Past events
    $oldevents_args = array(
        'post_type' 	=> 'event', 
        'post_status' 	=> 'publish',
        'meta_query'	=> array(
            array(
                "key" => "date",
                "value" => $today,
                "compare" => "<"
            )
        ),
        'posts_per_page' => -1,
        'orderby'  => 'meta_value_num',
        'meta_key' => 'date',
        'order'    => 'DESC',
    );
    $oldevents = new WP_Query($oldevents_args);
    if ($oldevents->have_posts() ):
       while ($oldevents->have_posts() ) :
            $oldevents->the_post();
            the_title();
       endwhile; 
    endif;
    wp_reset_postdata(); 

    In this example, the past events are displayed, the futur events are not.

    I’ve tested

    var_dump($today) // return '20190419'

    Where I’m loosing my hair :
    1) The two queries are exactly the same, only the “compare” argument is different.
    2) In the “futur event” query, if I replace

    
    "key" => "date",
    "value" => $today,
    "compare" => ">"
    

    by

    
    "key" => "date",
    "value" => '20190419',
    "compare" => ">"
    

    It works !!

    I also change the type of $today into ‘integrer’ but that doesn’t change anything. The futur event are still not showing.

    Hope someone can help,
    Thank you

    PS : sorry if I’m not on the right forum post.

  • Hi John,

    Thank you for your answer.
    I change my function and it works well.

    For the records :

    
    <?php
    // CF7 Kill all
    add_filter( 'wpcf7_load_js', '__return_false' );
    add_filter( 'wpcf7_load_css', '__return_false' );
    // Load only if shortcode
    function vanois_load_cf7() {
        // if shortcode in acf fields flexible content
        if(have_rows('flexible_content')) {
            while (have_rows('flexible_content')) : 
                the_row();
                $raw_data = get_row();
                $cf7_shortcode = preg_grep("/contact-form-7/", $raw_data);
            endwhile;
            if ($cf7_shortcode) {
                wpcf7_enqueue_scripts(); 
            }
        // else if no flexible-content, check shortcode in wp default editor    
        } else {
            global $post;
            if( has_shortcode( $post->post_content, 'contact-form-7')) {
                wpcf7_enqueue_scripts(); 
            } 
        }
    }
    add_action( 'wp_enqueue_scripts', 'vanois_load_cf7' );
    ?>
    
  • Hi everyone,

    Since “Options page” v1.1 you can use in your function.php :

    acf_set_options_page_capability( 'edit_themes' );
    where ‘edit_themes’ is a typical wordpress admin capability

    > “Options page” v1.1 release note and example here

    Or since “Options page” v1.2, you can setup capability in your function.php like this :

    function my_acf_options_page_settings( $acf_options_page_settings )
    {
      $acf_options_page_settings['title'] = 'Theme Options';
      $acf_options_page_settings['pages'] = array('Sub-page 1', 'Sub-page 2');
      $acf_options_page_settings['capability'] = 'edit_themes';
    
      return $acf_options_page_settings;
    }
    add_filter('acf/options_page/settings', 'my_acf_options_page_settings');
    

    Check the line : $acf_options_page_settings[‘capability’] = ‘edit_themes’;

    Hope you enjoy 😉

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