Support

Account

Home Forums ACF PRO How to call get field inside Woody Ad snippet

Helping

How to call get field inside Woody Ad snippet

  • Hi there!

    I created a snippet using Woody Ad snippets that displays Yotpo review widget.
    Now I would like to display reviews automatically for each custom post type by using this snippet in a custom field (text) called “Reviews”.

    The code looks like this:
    [wbcr_php_snippet id=”790″ name=”title”]

    How can I call the title of the custom post type inside the ” “?

    I tried
    [wbcr_php_snippet id=”790″ name=”$value = get_field( “title” );“]

    but this isn’t working. Anyone knows if this is possible and how to do it? 🙂

    Thanks a lot in advance!

  • Hi Chris,

    If i understand well, you’re trying to integrate your shortcode into your template file, for a specific custom post type.

    I think it’s better to store your acf value first and use it in your shortcode after.

    You could use something like this :

    <?php
    //First, you have to tell that you want a value of a single cpt
    $ID = get_the_id();
    //Then, you store your targeted value as $variable
    $title = get_field('title', $ID);
    
       //Finally you use your $variable to build your custom shortcode
       echo do_shortcode('[wbcr_php_snippet id="790" name="$title"]');
    
    ?>

    Let me know if it helps,

    RemSEO

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

The topic ‘How to call get field inside Woody Ad snippet’ is closed to new replies.