ACF options not working
This topic contains 11 replies, has 4 voices, and was last updated by  Paolo 6 years, 4 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support TicketTagged: acf, Theme Options
- 
		AuthorPosts
- 
		
			
				
June 17, 2019 at 5:47 pm #493469Hello, is there any way to get my custom ACF theme options to display? I’m echoing “get_field(‘social_facebook’, ‘option’)” in the footer, but it’s not working on any GeoDirectory page. June 17, 2019 at 9:50 pm #493495I realize that GD uses custom database tables for optimal performance, and I’m using “geodir_get_post_meta” for custom fields. But I’m also using global ACF options being in the header/footer of the site that break on GD pages. Is there a workaround for this? June 18, 2019 at 3:23 am #493527You are trying to attach ACF to a listing post type? June 18, 2019 at 1:04 pm #493601No, I’m using your GeoDirectory custom fields for the listing post type. But I’m using ACF fields for global theme options that display in the header and footer on all pages of the site (Facebook, Twitter, copyright, etc.) See here: 
 https://www.advancedcustomfields.com/resources/get-values-from-an-options-page/So for example on a single Place post, all my “get_field(‘xxxxx’, ‘option’)” are not working in the header and footer, completely separate from listing data. June 18, 2019 at 3:10 pm #493619The fact that we use our own db tables, doesn’t mean that we block ACF from working. I’m trying to understand what could be causing this. DO they work if you disable GeoDirectory? If the answer is yes, please provide a link, FTP and admin credentials and we’ll have a look. Thanks June 18, 2019 at 4:17 pm #493629This reply has been marked as private.June 18, 2019 at 4:21 pm #493631This reply has been marked as private.June 18, 2019 at 4:42 pm #493632Hi, I think we use that filter to avoid other plugin messing with our queries while on our pages. I’ve flagged this for a developer to see if we can come up with a workaround. Thanks June 18, 2019 at 5:02 pm #493639That makes sense. I appreciate you looking into this. Looks like others are continuing to struggle with ACF as well. 🙂 June 19, 2019 at 9:43 am #493760Hi Aleks, I have added following snippet to fix conflixt between GeoDirectory and ACF. /** * Fix: GeoDirectory & ACF conflict */ function gd_snippet_190619_posts_where( $where, $wp_query ) { global $wpdb; if ( ! empty( $wp_query ) && geodir_is_geodir_page() ) { if ( $field_key = $wp_query->get( 'acf_field_key' ) ) { $where .= $wpdb->prepare(" AND {$wpdb->posts}.post_name = %s", $field_key ); } if ( $field_name = $wp_query->get( 'acf_field_name' ) ) { $where .= $wpdb->prepare(" AND {$wpdb->posts}.post_excerpt = %s", $field_name ); } if ( $group_key = $wp_query->get( 'acf_group_key' ) ) { $where .= $wpdb->prepare(" AND {$wpdb->posts}.post_name = %s", $group_key ); } } return $where; } function gd_snippet_190619_pre_get_posts( $wp_query ) { if ( ! empty( $wp_query ) ) { add_filter( 'posts_where', 'gd_snippet_190619_posts_where', 11, 2 ); } } add_action( 'pre_get_posts', 'gd_snippet_190619_pre_get_posts', 11, 1 );Please check and let us know. Kiran June 19, 2019 at 6:18 pm #493860Kiran, this works perfectly so far! I’ve tested a theme option as well as a post type field for Place. Thanks so much for this! Shoutout to Paolo for pushing this through. 🙂 June 19, 2019 at 6:30 pm #493862I’m glad we could fix it… You are welcome 🙂 
- 
		AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket