ACF options not working

This topic contains 11 replies, has 4 voices, and was last updated by  Paolo 5 years, 6 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: ,

  • Author
    Posts
  • #493469

    Aleks Szymanski
    Free User
    Post count: 23

    Hello, 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.

    #493495

    Aleks Szymanski
    Free User
    Post count: 23

    I 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?

    #493527

    Alex Rollin
    Moderator
    Post count: 27815

    You are trying to attach ACF to a listing post type?

    #493601

    Aleks Szymanski
    Free User
    Post count: 23

    No, 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.

    #493619

    Paolo
    Site Admin
    Post count: 31206

    The 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

    #493629

    Aleks Szymanski
    Free User
    Post count: 23
    This reply has been marked as private.
    #493631

    Aleks Szymanski
    Free User
    Post count: 23
    This reply has been marked as private.
    #493632

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    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

    #493639

    Aleks Szymanski
    Free User
    Post count: 23

    That makes sense. I appreciate you looking into this. Looks like others are continuing to struggle with ACF as well. 🙂

    #493760

    Kiran
    Moderator
    Post count: 7069

    Hi 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

    #493860

    Aleks Szymanski
    Free User
    Post count: 23

    Kiran, 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. 🙂

    #493862

    Paolo
    Site Admin
    Post count: 31206

    I’m glad we could fix it… You are welcome 🙂

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount