Shortcode not displaying

Support MB Custom Post Type Shortcode not displayingResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #28268
    auldreekieauldreekie
    Participant

    I'm using Metabox Custom Fields to add fields to a Metabox custom post type, which in turn is used to display markers and popups on a leaflet.js map.

    When editing custom posts, admin users should be able to either add some free text, or paste a shortcode that will display the contents of that shortcode in the map popup.

    The shortcode just holds a chunk of predefined text, edited in a third party content blocks WP plugin. The text can then be edit once > change in multiple map markers.

    The custom field that the shortcode is added to is location_content_shortcode.

    It's called in my list.js file like this:

    var popupContentShortcode = '';
            if (location.location_content_shortcode) {
                popupContentShortcode = '<p>' + location.location_content_shortcode + '</p>';
            }

    But on the website frontend, just the shortcode shows - [ls_content_block slug="tier-1"]

    Any idea how I can fix this?

    #28273
    Long NguyenLong Nguyen
    Moderator

    Hi,

    JavaScript does not support parsing the shortcode and render it. You can follow this topic to know how to use JavaScript in PHP code to parse the shortcode.
    https://stackoverflow.com/questions/47117329/adding-javascript-to-php-wordpress

    Or follow this article to show more address markers on a map https://metabox.io/display-all-listings-on-a-map/

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.