I am using the Orbit Slider plugin successfully on my site. The plugin supports its own categories. I would like to embed the slider within my page.php template but allow each page to have it's own slider based on the category.

Inside my page.php I have this:

<?php echo do_shortcode('[orbit-slider category="page"]'); ?>

the category "page" is just the name of a category I created. It will display only slides that come from category.

Instead of hard-coding the category, I wanted to use custom fields so that on each individual page my client can specify a category to be shown. I have tried something like this but it's causing an internal server error:

<?php echo do_shortcode('[orbit-slider category="' echo get_post_meta($post->ID, "slide-category", true);'"]'); ?>

[09-Feb-2012 20:05:08] PHP Parse error: syntax error, unexpected T_ECHO in /public_html/wp-content/themes/techmd960/page.php on line 21

Can someone point out what I am doing wrong? I figure it has to do with the quotes (double and single) but can't figure it out.

Essentially I just want to output the custom field "slide-category" as the value for category="" in the shortcode.


You've got an echo inside an echo.

Rewrite you code like this:

<?php echo do_shortcode('[orbit-slider category="' . get_post_meta($post->ID, "slide-category", true) . '"]'); ?>

This will concatenate things instead. and give you '[orbit-slider category="5"]' inside the do_shortcode() function.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.