Support

Account

Forum Replies Created

  • Currently the Post Object field (Default Posts) is selected on the Posts Page (index.php) but that could easily but transitions to Options as the Posts Page does not really serve much purpose except to serve as a listing for posts.

  • I had multiple things going on but in the end this was the code that worked for me. Feel free to dissect out of this what you need. In my case the client wanted the featured projects to be at the top and then added the criteria that they would also like to exclude some posts from displaying in the list but still wanted them accessible as single posts. With this my featured posts were at the top and my excluded posts did not display. And if a user clicked both boxes it defaulted to not display.

                        'post_type'         => 'work',
                        'post_status'       => 'publish',
                        'posts_per_page'    => -1,
                        'meta_key'          => 'featured_project',
                        'orderby'           => 'meta_value date',
                        'order'             => 'DSC',
                        'meta_query'        => array(
                            'relation' => 'OR',
                            'exclude_posts' => array(
                                'relation' => 'OR',
                                array(
                                    'key'       => 'exclude_project',
                                    'compare'   => '!=',
                                    'value'     => '1'
                                ),
                                array(
                                    'key'       => 'exclude_project',
                                    'type'      => 'BOOLEAN',
                                    'value'     => false
                                ),
                                array(
                                    'key'       => 'exclude_project',
                                    'compare'   => 'NOT EXISTS'
                                ),
                            ),
                            'featured_posts' => array(
                                'relation'  => 'AND',
                                array(
                                    'key'       => 'featured_project',
                                    'value'     => '1',
                                    'compare'   => '='
                                ),
                                array(
                                    'key'       => 'exclude_project',
                                    'compare'   => '!=',
                                    'value'     => '1'
                                ),
                            ),
                        ),
                        
                    );
  • when I var_dump the variable to see what the unchecked boxes value is it says false or null

    The false return is from a post that has had the box checked, updated and then unchecked and updated. the null return is from posts that have not been updated.

    Your code is logical but the database is not recording a 0 value for an unchecked box and I can’t go through every post and tick the box and save and then untick the box and save just to get it to reflect some value.

    If you have any other ideas I’d love to see them. Thanks for your help!

  • I am in a similar situation. I have added a true/false checkbox to existing fields and it doesn’t recognize an unchecked value as 0. When I echo the value of a checked box I get 1 and an unchecked box returns nothing. I have tried the bulk update posts to try to get the database to recognize this new fields and record a 0 but it doesn’t seem to work.

    I have been working through this on another post
    https://support.advancedcustomfields.com/forums/topic/true-false-no-value-for-false/#post-60222
    but I have not had any success. I know the code makes sense but the results don’t display.

    I’d love to know what you did to resolve this issue.

  • Unfortunately this did not have any real effect.

                    $args = array(
                        'post_type'         => 'work',
                        'post_status'       => 'publish',
                        'posts_per_page'    => -1,
                        'order'             => DSC,
                        'meta_query'        => array(
                            'relation' => 'OR',
                            array(
                                'key'       => 'exclude_project',
                                'value'     => '0',
                                'compare'   => '='
                            ),
                            array(
                                'key'       => 'exclude_post',
                                'compare'   => 'NOT EXISTS'
                            )
                           
                        ),
                    );

    I still see all my posts. The ones with a value if 1 are still showing up in my query

    $query = new WP_Query( $args );
                    if ( $query->have_posts() ) :
                        while ( $query->have_posts() ) : $query->the_post();
                            get_template_part( 'template-parts/content', 'work' );
                        endwhile;
                            wp_reset_postdata();
                    else:
                        get_template_part( 'template-parts/content', 'none' );
                    endif;
  • Thank you for your response. I suspected it might not do what I needed but the plugin is so powerful I didn’t want to assume what it could and could not do.

    I have looked into the Nav Roles Plugin and will explore it a little further.

    Before I close this thread can ACF create additional roles or should I use a role management plugin like https://wordpress.org/plugins/user-role-editor/

    Thank You

  • I’m not referring to the menu’s that exist in the admin area. I am referring to menus that I create for navigation purposes. For example I may want to hide possible menu selections in my navigation for users that are not logged in or perhaps this menu selection would only be available for gold lever members. Another example might be if I have a menu selection item that says login. I would want to alter the content of that menu to logout once the users has logged into the account.

    Thanks!

  • In this example the Field Group Title is Apprenticeship On Demand and the post id is 263 (visible in the url)

    http://www.kokoruz.com/acf/acf-title.png

    When I put the code for the ACF into a page section the title is always hard coded but I would rather make the section title dynamic to the Field Group Title.

    It would also be useful to dynamically pull the Label from the Fields within the Group. In this example the Field Labels are Description and Image.

    Is it possible to pull the Title of the Field Group and the Labels from within the Field Group?

  • Not sure I asked the question right. The first step in the process it to create a Field Groups Title. Then you create individual field Labels within the Field Groups.

    I’m not interested in the label names but rather the Field Groups Title. It would seem like I could take the post ID and echo the Field Groups Title. Right now in most cases my Field Groups Title is the same as what I hard could into my templates. It would be nice to pull the post id to dynamically create the title that display in the front end.

    Thanks!

  • Thanks John. These questions have been a learning experience for me for future projects as well. The FAQs is only a few entries, that’s why I did not make it a custom post type but since this issues arose I thought I would turn it into a learning moment and reach out to the community.

    Thank you for all your feed back. It looks like I need to read up on the options page. If you have any links or youtube videos that you think are helpful I would appreciate you sharing.

    Thanks again for all your feed back. It has been very helpful.

  • I thought that was the case. Was hoping I could have the custom fields and data appear in the backend of both locations but as you both stated, either use the options page or designate 1 of the 2 locations for the custom fields interface to exist in the backend and code the acf with the post ID.

    Can either of you answer this question. Can content that has already been entered in the custom fields be moved? By this I mean, I set up a custom field for the home page and entered all the information. Now the client has decided they want to move it off the homepage to an alternate page. When I reassign the location the custom fields show up on that location but none of the data. Is it possible to move the data with the custom fields in the backend or will I need to reenter all of the information.

    Thanks!

  • One more question. Is there a trick to doing nested tabs or is that not possible?

  • I did some further research and I found the tab layout in the drop down. It will be put to good use in the future.

    Can you provide a code sample of the ACF loop using a tab?

    BTW – I could not use the options page because I have repeated values and the options page only supports 1 unique filed value. What I did was created pages for each item and then I referenced the page ID the_sub_field(‘course_title’, 569);

  • Under Layout I only see Table and Row.

    Could you tell me more about the Tab Layout?

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