Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
    
thanks that worked. –  gteh Feb 10 '12 at 5:15
1  
Please remember to mark it as the accepted answer if it worked :-) –  EAMann Feb 10 '12 at 16:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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