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.

Hi I'm trying to use this plugin: http://wordpress.org/extend/plugins/wordpress-simple-website-screenshot/

I am supposed to use the shortcode: [screenshot url="www.example.com"] Because I am writing the code in the single.php file I am using:

<?php echo do_shortcode( '[screenshot url="www.example.com"]' ); ?>

But, my problem is that the URL is defined in the title of the post, so I tried:

<?php echo do_shortcode( '[screenshot url="<?php the_title(); ?>"]' ); ?>

with no luck.

Is it possible to do a workaround on this?

share|improve this question
    
I need something similar & I can't get my code to work. Please help. <?php echo do_shortcode( '[expand title="'.the_title().'"]'.the_content().'[/expand]'); ?> –  user4561 Apr 10 '11 at 1:04
    
@Elizabeth, Hi could you please post a new question with more details. –  Chris_O Apr 12 '11 at 6:18
add comment

2 Answers 2

up vote 2 down vote accepted

You're trying to execute PHP inside a string! Instead, concat the string;

<?php echo do_shortcode( '[screenshot url="' . get_the_title() . '"]' ); ?>
share|improve this answer
    
Thanks! It worked, I only needed to remove a space "'HERE. get_the_title(). For others: Use <?php echo do_shortcode( '[screenshot url="'. get_the_title() . '"]' ); ?> –  Anders Mar 15 '11 at 15:15
1  
That space is for readbility. It won't be included in the final string!!! phphowto.blogspot.com/2006/12/concatenate-strings.html –  TheDeadMedic Mar 15 '11 at 17:02
add comment

Your problem is that <?php the_title(); ?> inside quotation marks doesn't really works change:

<?php echo do_shortcode( '[screenshot url="<?php the_title(); ?>"]' ); ?> 

to :

<?php echo do_shortcode( '[screenshot url="'.the_title().'"]' ); ?> 
share|improve this answer
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.