Add a shortcode with variable

This topic contains 1 reply, has 2 voices, and was last updated by  Alex Rollin 4 years, 8 months ago.

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

Open Support Ticket
  • Author
    Posts
  • #505723

    sonyliston
    Expired Member
    Post count: 58

    Hello,

    We’re trying to place a shortcode inside the profile tab.

    The problem is that we need to place the title of the listing as Tag inside the shortcode.

    We were using this code before the Geodir V2 and was working

    <?php $meta_value = geodir_get_post_meta($post->ID, 'geodir_professional_name', true ); ?>
    <?php if  (!empty( $meta_value )): ?>
     <?php echo do_shortcode('[newsbox style="nb6" display="tag" tag="'.geodir_get_post_meta($post->ID, 'geodir_professional_name', true).'" number_of_posts="3" title="Latest News"]'); ?>
    <?php endif; ?>

    And now with the new version that allows to add shortcode inside the profile tab, we’re trying to create a shortcode with the variable picking up the Listing name. But it doesn’t seem to be working now. (If we use this code without the variable of ‘geodir_get_post_meta()’ and place a tag, then it works. So the problem is with that)

    function LatestNewsShortcode() {
      return do_shortcode('[newsbox style="nb6" display="tag" tag="'.geodir_get_post_meta($post->ID, 'post_title', true).'" number_of_posts="3" title="Latest News"]');
    
    }
    add_shortcode('latest-news', 'LatestNewsShortcode');
    #505740

    Alex Rollin
    Moderator
    Post count: 27815

    Hello,

    we have an example for that here:

    https://wpgeodirectory.com/docs-v2/faq/customizing/#custom-integrations

    If you need hands on help with customizing you can contact a GD Expert here:

    https://geodirectoryexperts.com

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

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

Open Support Ticket