Title: Custom post causing post link bug
Last modified: March 2, 2017

---

# Custom post causing post link bug

 *  Resolved [Sam](https://wordpress.org/support/users/forbiddenchunk/)
 * (@forbiddenchunk)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/custom-post-causing-post-link-bug/)
 * I have a custom post
 *     ```
       <?php			 
       		$fuel_cards_posts = 'p=599 & post_type="adverts" & showposts=99999';
       	$posts = get_posts($fuel_cards_posts); foreach($posts as $post) {
       		global $post;
       ?>
       	<a href="<?php the_field('url'); ?>" target="_blank"><img src="<?php the_field('image'); ?>" alt="<?php the_title(); ?>"></a>
       <?php } ?>	
       <?php wp_reset_query(); ?>
       ```
   
 * Yet when I click a post on the homepage, the URL is correct but the page loads
   that post with the title and nothing else?
 * I have WP Reset Query but still not working…
 * Anyone got any ideas?
 * Thanks in advance
    -  This topic was modified 9 years, 2 months ago by [Sam](https://wordpress.org/support/users/forbiddenchunk/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Pieter Bos](https://wordpress.org/support/users/senlin/)
 * (@senlin)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/custom-post-causing-post-link-bug/#post-8865446)
 * Your query seems to be messed up. Space usually don’t work in them and neither
   do ampersands… Have a look at [the Codex entry on WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
   how to do it properly.
 *  [1naveengiri](https://wordpress.org/support/users/1naveengiri/)
 * (@1naveengiri)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/custom-post-causing-post-link-bug/#post-8865464)
 * use WP_Query.
 *  Thread Starter [Sam](https://wordpress.org/support/users/forbiddenchunk/)
 * (@forbiddenchunk)
 * [9 years, 2 months ago](https://wordpress.org/support/topic/custom-post-causing-post-link-bug/#post-8889107)
 * Thanks @1naveengirl that got me on the right track, cheers!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Custom post causing post link bug’ is closed to new replies.

## Tags

 * [custom post](https://wordpress.org/support/topic-tag/custom-post/)
 * [post](https://wordpress.org/support/topic-tag/post/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [Sam](https://wordpress.org/support/users/forbiddenchunk/)
 * Last activity: [9 years, 2 months ago](https://wordpress.org/support/topic/custom-post-causing-post-link-bug/#post-8889107)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
