• Resolved patrizia.vergassola

    (@patriziavergassola)


    Hello,

    I’ve extended page template by adding two custom fields.
    I’m trying to display one of these in one of the shortcode templates available with WP Bakery Plugin.
    Here’s the code I’m using:

    $ID = ‘{{ post_data:ID }}’;
    $output .= do_shortcode(‘[pods name=”page” id=”‘. $ID .'” template=”Data/e Spettacolo”]’);
    echo $output;

    everything works fine if I don’t use the $ID variable, but If i use it I display nothing. If I try to print the content of the $ID variable it’s the correct ID of the page.
    I’m really stuck at this, can you please help?

    Thank you in advance,
    Patrizia

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Jim True

    (@jimtrue)

    So you’re getting the results you want if you don’t pass the id variable, is that correct?

    If you’re placing this on the page that you’re wanting to show the content from, you don’t need to pass the ID. The Pods Shortcode is smart enough to identify the post id automatically. It looks like you’re also asking the template you’re pulling in to process shortcodes. It could be something inside that template that might be stepping on the process.

    However, if you’re getting the result you’d like from leaving off id, just leave off id.

    Thread Starter patrizia.vergassola

    (@patriziavergassola)

    No, unfortunately not cause it’s inside a loop and If I don’t pass the value of the variable I get the same result for all the pages.

    Now I’ve tried not passing the ID but I always get the same value, the last of the loop.

    Patrizia

    Thread Starter patrizia.vergassola

    (@patriziavergassola)

    Plugin Contributor Jim True

    (@jimtrue)

    I think you need to validate you can get the right output if you try this just in a standard WordPress page _outside_ of the Visual Composer. ie

    [pods name="page" id="5853" template=”Data/e Spettacolo”] << little concerned those are pretty quotes as I copied them from your code above.

    You need to make sure the shortcode works outside of your code to validate that’s not where the problem arises.

    • This reply was modified 6 years, 2 months ago by Jim True. Reason: missed a space in my code section
    Thread Starter patrizia.vergassola

    (@patriziavergassola)

    Hello Jim,
    it works, but I think it’s something related to the $ID variable I’m using.
    If I print the variable the ID is correct, If I use it inside the shortcode isn’t working.
    Can it be something related to the type of the variable (integer, string)?
    Patrizia

    Plugin Contributor Jim True

    (@jimtrue)

    Not sure, as you’re getting deep into PHP handling of variables at that point and I’m not a Developer. It doesn’t sound like it’s specifically with Pods, just how the value is being presented to the shortcode in your code and that’s going to take some debugging on your part.

    You’re welcome to join our Slack chat https://pods.io/chat/ and join the #dev-chat channel. We have a lot of developers who hang out in that channel and who developer in Pods and some who also develop for Pods, so it’s a good place to bounce your PHP issues around and get some feedback. It’s not ‘support’ and it’s not staffed so it does require patience for answers, but everyone is very friendly and helpful.

    I’m going to mark this one resolved since you can tell from using the shortcode directly that it works. It’s just something with how you’re handling your custom code that isn’t working.

    Hi, guys.
    I am not sure if my issue related to this one, but i have some problem with my ID as well.

    I have a POD which has a field type Plain Text. We are using it to hold shortcode which then uses to output some form with do_shortcode function in our template. It worked well(and even continue work after downgrade the plugin to 2.6.11 version), but at some moment in 2.7.x version that field don’t to save value like [newsletter_signup_form id=2] and the problem there is an id=2. If i trying to save [newsletter_signup_form] – all ok. Database postmeta table meta_value field contains that value, but if i add id=2 as a parameter meta_value field in database become empty for some reason

    Plugin Contributor Jim True

    (@jimtrue)

    @krombox this doesn’t sound exactly like what the person above was referencing. If you had something that was working and is suddenly not working with 2.7, you should open a bug report per our Support Policy:

    If you’ve uncovered a Bug or have a Feature Request, we kindly request you to create an Issue on our GitHub Repository at https://github.com/pods-framework/pods/issues/new. Please be very specific about what steps you did to create the issue you’re having and include any screenshots or other configuration parameters to help us recreate or isolate the issue.

    Before making an issue decided to do some debug and as a result found what was the problem. Plain Text field has Allow shortcodes checkbox on Additional field options tab. This was never checked on our site and works well before we updated to 2.7.x branch. After tick this option all started working well. Thanks

    Plugin Contributor Jim True

    (@jimtrue)

    Sounds like it was ignoring it before, which would be highly odd. Glad you figured it out @krombox.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Shortcode Not Working’ is closed to new replies.