Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @developer04pegasus

    Looks like very strange thing you are facing. Make sure you have latest version of plugin activated.

    Try fetching the things with below field for shortcode.
    – Have you added your shortcode in WYGIWYG editor or used with do_shortcode() method?

    As you are in test page so you can try it with [acf field=”name” post_id=”5422″]

    Thread Starter developer04pegasus

    (@developer04pegasus)

    Hi Krupal

    Thanks for your reply.

    I tried using the following, but it did not work.
    [acf field=”name” post_id=”5422″]

    While further debugging I found that the shortcodes are returning no values at all.

    So, I wrote the following code in my child functions.php

    add_shortcode( ‘acf_shortcode’, ‘acf_shortcode_callback_function’ );

    $value = get_field( “oragnisation_name_partner” );

    function acf_shortcode_callback_function( $atts ){
    if( $value ) {
    echo $value;
    } else {
    echo ’empty’;
    }
    }

    and then used this shortcode: [acf_shortcode] on the testing page below.
    https://circulareconomyalliance.com/test-acf-shortcode/

    and as you can see, it returns empty.

    But that doesn’t make sense, because in the wordpress backend – edit user page, you can actually see the real values stored properly.

    Here’s the screenshot – https://imgur.com/a/h0aT4u0

    FYI, I am using the ACF plugin with wpforms custom meta. And it’s working fine as you can see the data being stored and reflected properly.

    Could you please help me see why this is happening?

    Thank you!
    Lavanya

    Hi @developer04pegasus

    Just want to ask that did you copy the given shortcode([acf field=”name” post_id=”5422″]) and pasted as it is? Because it could be an issue with double quote which are copied.
    So try with our norMal quote which we use from text editor. [acf field="name" post_id="5422"]
    According to the shortcode, it should work.

    For your shortcode which you created in functions.php need to modify somehow like the below code:

    add_shortcode( 'acf_shortcode', 'acf_shortcode_callback_function' );
    
    function acf_shortcode_callback_function() {
    
    	ob_start();
    
    	$value = get_field( 'oragnisation_name_partner', YOUR-POST-ID );
    	
    	if ( $value ) {
    		echo $value;
    	} else {
    		echo 'empty';
    	}
    
    	$output = ob_get_contents();
    	ob_end_clean();
    	return $output;
    }
    Thread Starter developer04pegasus

    (@developer04pegasus)

    Hi Krupal…Thanks again for your kind reply.

    I tried doing both the suggestions above, but sadly none of them worked.

    There is still no difference when we changed the quotes in the first shortcode. Nothing appears on the page.

    and the function change in my functions.php file still echoes ’empty’

    Clueless about why it could be happening!

    Here are the screenshots: https://imgur.com/a/oXvcYwF
    and this is the link to the page: https://circulareconomyalliance.com/test-acf-shortcode/

    Hi @developer04pegasus

    Looks like very strange issue, can you just try with disabling all plugins and keep only ACF activate and check?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Both Shortcode and ‘Display a field’ PHP tag not able to fetch data’ is closed to new replies.