Use Shortcode in Custom Post Type

Posted in: Newspaper
Post count: 31

Hi,

I’m trying to insert this shortcode into a custom post type (I’ve made a copy of single.php and renamed it to single-photo.php)

[vc_row][vc_column][vc_media_grid include="115125,115126,115127,115128,115129,115130"][/vc_column][/vc_row]

http://beta.virtualfestivals.com/photo/metallica-at-reading-festival-2015/ is the page in question. The code you see is what I output to make sure what I am doing is right. However when actually doing the code, I get an error in Google Chrome console

Code

<?php
$image_ids = get_field(‘photo_gallery’, false, false);
$shortcode = ‘[vc_row][vc_column][vc_media_grid include="' . implode(',', $image_ids) . '"][/vc_column][/vc_row]‘;
echo $shortcode ;
echo do_shortcode( $shortcode );
?>

Error

Uncaught Error: Syntax error, unrecognized expression: {‘status’:’Nothing found’}

Now, if I copy/paste that into the editor, it works but obviously this is not what I need as I need the IDs based off a custom field created using the ACF plugin

Any advice?

Post count: 31

It works when I use it in

page.php

but not in

single.php

or any copy of it.

The shortcode works outside the editor when it is actually included within the editor!!!

Also

[vc_row][vc_column][vc_images_carousel images="115119,115038,115036,115035"][/vc_column][/vc_row]

works fine so it seems to be an issue with

vc_media_grid

Post count: 7909

Hi,

The media grid has a different syntax as you can see – http://screencast.com/t/zCyOkk05J

Thanks!

Post count: 31

Hi,

I’ve tried that but it doesn’t work. I read somewhere on the official plugin thread that it isn’t allowed due to security…. shame

JJ

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.