Just when I thought I’d finished with all this php mallarky I spot another bug…
Basically I post a url, it spits it out. Sometimes I post the same url and I don’t want the duplicates to show up.
Here’s the code:
<?php
query_posts('');
while (have_posts()) : the_post();
$content = parse_url(strip_tags(get_the_content()));
$url = $content['host'];
?>
<li><a href="http://<?php echo $url; ?>"><?php echo $url; ?></a></li>
<?php endwhile;?>
I’ve tried modifying the loop to not fetch duplicate post ID’s but I can’t get it to work, either does nothing different or prints nothing at all. I’ve tried loading the $url into an array and then using array_unique() but again, no success, just spits out “Array Array Array” or errors. I’m sure it’s easier than I think, I just can’t get the code quite right I suspect…
I’d love some help please, I’ve been at this for a while and I’m all out of ideas
Why not try taking a look at the WP_Query options that WordPress has implemented over the past couple of releases, I have always found these to be a more useful approach with the inclusion of Arrays and such like.
You can check out the codex here: http://codex.wordpress.org/Class_Reference/WP_Query
While not a direct answer it may lead you to a definitive answer in your quest!
I figured it out, well, someone kindly helped me 🙂
Cheers,
Craig.