0

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?

  • 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
2

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

<?php echo do_shortcode( '[screenshot url="' . get_the_title() . '"]' ); ?>
  • 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
0

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().'"]' ); ?> 

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.