Title: the_permalink issue
Last modified: August 19, 2016

---

# the_permalink issue

 *  [salimk786](https://wordpress.org/support/users/salimk786/)
 * (@salimk786)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/the_permalink-issue/)
 * Hello,
    I was on the irc and I am having a similar problem as was someone else.
   Here is what i’m trying to do:
 *     ```
       <?php
   
       $cat_image = get_post_meta($post->ID, "catimage", true);
       $cat_url = the_permalink();
       $out = '<span><a href="' . $cat_url . '"><img src="' . $cat_image . '" border="0"></a></span>';
       echo (!empty($cat_image) && strpos($cat_image, 'thumbnail')) ?  $out  : '';
       ?>
       ```
   
 * The problem is that the_permalink() does an echo and not a return. So I am can
   capture the string because its echoed out.
 * If you’re wondering why i am checking strpos is because I have a category which
   has 12 posts. Only a few of them have a custom field for catimage (category image).
   If they have that field, grab the value – the image path.
 * What i’ve noticed is that the posts that do not have the custom field, it still
   spits out the site (www.site.com/category/month/day/year/) which it shouldn’t
   but thats for another day. Today i need your help in getting the_permalink.
 * thanks. Please post anycode it would be great.

Viewing 1 replies (of 1 total)

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 4 months ago](https://wordpress.org/support/topic/the_permalink-issue/#post-681674)
 * Change your assignment of the permalink to:
 * `$cat_url = get_permalink();`

Viewing 1 replies (of 1 total)

The topic ‘the_permalink issue’ is closed to new replies.

## Tags

 * [the-loop](https://wordpress.org/support/topic-tag/the-loop/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 1 reply
 * 2 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [18 years, 4 months ago](https://wordpress.org/support/topic/the_permalink-issue/#post-681674)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
