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.

Help!

I am trying to create a Digg-clone by integrating "BM Shots" (a webpage thumbnail generator) with "Recommended Links" (a social voting plug-in for Wordpress). Recommended Links allows for user submitted URLs to be displayed via "the_permalink" tag. I'm trying to use BM Shots to generate web page thumbnails based on user submitted URLs. BM Shots work just fine, but I can't get BM Shots to recognize "the_permalink".

The default usage of BM Shots looks like this...

            <?php
            $url = 'http://www.binarymoon.co.uk/';
            $width = 300;
            echo bm_mshot ($url, $width);
            ?>

But I want it to work like this...

            <?php
            $url = the_permalink;
            $width = 300;
            echo bm_mshot ($url, $width);
            ?>

I'm able to get it to work with other Wordpress tags, which is useless, but not "the_permalink." I'm not a coder, so I could use some suggestions, even if they seem obvious.

EDIT//

Here is what the loop looks like

            global $wp_query;
            $plugin_settings = get_option( 'reclinks_plugin_settings' );
            $start =  ( $wp_query->query_vars['paged'] ) ? 
            ( ( $wp_query->query_vars['paged'] -1 ) * $wp_query->query_vars['posts_per_page'] + 1) : 1;
            ?>
            <?php if ( have_posts() ) : ?>
            <ol style="list-style-type:none; margin-left:-22px;" start="<?php echo $start; ?>">
            <?php while ( have_posts() ) : the_post(); ?>
            <li style="margin-top:30px;">
            <img src="<?php
            $url = the_permalink;
            $width = 300;
            echo bm_mshot ($url, $width);
            ?>" width="100"  style="float:left;">   
            <h2 style="margin-bottom:-7px;"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
            <small> <?php reclinks_favicon(); ?> <?php reclinks_domain(); ?></small>
            <br><small><?php reclinks_votebox(); ?></small>
            </li>
            <?php endwhile; ?>
            </ol>
            <?php else : ?>
            <p><?php _e( 'No recommended links yet. Add one?', 'gad_reclinks' ); ?></p>
            <?php endif; ?>
share|improve this question
    
"When I tried using get_permalink() it sent the URL of the posting itself rather than the user submitted URL." - please rewrite your question. The Post Permalink is clearly not what you're after. You need to edit your question to indicate how you're storing the URL that you want returned. –  Chip Bennett Feb 24 '12 at 21:35
    
Can you show some code where you want to have the thumbnail and how you get the data now (on your frontpage, right?). –  Rob Vermeer Feb 24 '12 at 21:46
    
update: see original posting for my loop code –  Richard Feb 24 '12 at 22:30
    
Thanks for the edit. Can you clarify/highlight the part of that code that represents where the user enters the URL on the front end? –  Chip Bennett Feb 24 '12 at 22:42
    
$url = get_permalink(); should work, because the_permalink(); represents the url in the h2 anchor element. Btw: i would do <img src="<?php echo bm_mshot (get_permalink(), 300);" width="100" style="float:left;"> –  Rob Vermeer Feb 24 '12 at 23:17
show 1 more comment

3 Answers

up vote 3 down vote accepted

the_permalink() is actually filtered in the Recommended Links plugin to echo a custom meta field called _href. If you want access to that field without echoing it, you can use get_post_meta( $post->ID, '_href', true ).

Try something like this in your loop:

global $post; // may or may not be necessary
$url = get_post_meta( $post->ID, '_href', true );
$width = 300;
echo bm_mshot ($url, $width);
share|improve this answer
    
Awesome! Thanks for answering! –  Chip Bennett Feb 25 '12 at 0:20
    
Thanks everyone for all of the help (especially Nathan/goldenapples). Funny enough, I was able to get it working just as goldenapples posted his reply. <?php echo bm_mshot (gad_reclinks_permalink(), 300); ?> It turns out both methods work, in case anybody is interested. Anyway, thanks again for all the quick replies. –  Richard Feb 25 '12 at 0:36
add comment

If you are using this code outside the Loop, then the_permalink() won't be available. But, I suspect that you're using it within a post, so that shouldn't be a problem.

One major issue: you need to return the permalink, not echo it. So you don't want to use the_permalink(), but rather get_permalink():

<?php
$url = get_permalink;
$width = 300;
echo bm_mshot ($url, $width);
?>

And if that doesn't work, you might try pulling it out of the $post object directly:

<?php
global $post;
$url = $post->post_permalink;
$width = 300;
echo bm_mshot ($url, $width);
?>
share|improve this answer
    
Yes, I am using it within the loop, in a post. I just tried your suggestion of "pulling it out of the $post object directly," but that didn't work either. –  Richard Feb 24 '12 at 20:57
add comment

the_permalink() echoes the permalink, get_permalink() returns the permalink. So I think using get_permalink() will fix your issue.

<img src="<?php echo bm_mshot (get_permalink(), 300); ?>" width="100" style="float:left;">
share|improve this answer
    
When I tried using get_permalink() it sent the URL of the posting itself rather than the user submitted URL. –  Richard Feb 24 '12 at 20:48
    
Where is the input coming from? An input field somewhere? Please explain your situation a bit more. –  Rob Vermeer Feb 24 '12 at 21:03
    
Visit camerabooru.com to see what I'm talking about - This is my test site so please mind the mess –  Richard Feb 24 '12 at 21:31
1  
Then you need to rewrite your question to indicate what you're actually doing, because the Post Permalink is not the URL you're after here. –  Chip Bennett Feb 24 '12 at 21:33
1  
"But the url is inserted via the_permalink tag" - No, it's not. The the_permalink() template tag is used to echo the post permalink. –  Chip Bennett Feb 24 '12 at 22:41
show 1 more 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.