• Resolved tamiheaton

    (@tamiheaton)


    Hi – For layout reasons, i need to insert the shortcode directly into the single.php file. I am not able to get this to work at present.

    I tried inserting the shortcode directly into the single.php file, and the code was visible in the content area rather than displaying thumbnails. I have also tried using shortcode_do for display… but this does not seem to be working, either. I used:

    <?php echo do_shortcode( ‘[thumbnailgrid cat=’4′ posts=’12’ type=’post’ order_by=’date’ order=’ASC’]’ ); ?>

    i also tried this – because it was in an example the wordpress site had in their instructions for shortcode_do:

    <?php echo do_shortcode( ‘[thumbnailgrid cat=’4′ posts=’12’ type=’post’ order_by=’date’ order=’ASC’]’ ) ?>

    then i tried using the advanced custom fields plugin to add another text field to my page that i could display separately from the main one… but it had the same results as if i had inserted the shortcode directly into single.php.

    i am not really a php developer and i’m not sure what i’ve got wrong. i have been unable to find a reference in the documentation that explains what code to use to insert directly into the post code, so i’m winging it on my own here. can anyone help?

    thanks!

    https://wordpress.org/plugins/thumbnail-grid/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author A. Jones

    (@nomadcoder)

    I’m not sure, I’ve never used do_shortcode but maybe this will work. I replaced the quotes containing your string with double quotes.

    echo do_shortcode( “[thumbnailgrid cat=’4′ posts=’12’ type=’post’ order_by=’date’ order=’ASC’]” );

    Usually I would use single quotes to contain the text and double quotes in the text but it should work the other way around too.

    echo do_shortcode( ‘[thumbnailgrid cat=”4″ posts=”12″ type=”post” order_by=”date” order=”ASC”]’ );

    Thread Starter tamiheaton

    (@tamiheaton)

    that did it!! thank you so much, i really, really appreciate the help 🙂 i love this plugin, and i’m planning to use it again on my very next project 🙂

    Plugin Author A. Jones

    (@nomadcoder)

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Using shortcode in single.php?’ is closed to new replies.