Get posts – remove duplicate titles from loop
-
Hi,
I have a custom posts set up to run a catalogue. Many of the items in the catalogue have exactly the same title.
Im using the code below to output all the page titles as a list that you can click on as a search.
So I’m using the title (not linking to a post) to create a search query in effect. As there are multiple titles i want to remove duplicates in the list, is this possible?
For example currently titles you would see:
Cats
Cats
Cats
DogsBut i need:
Cats
Dogs<?php $lastposts = get_posts('&post_type=catalogue&orderby=title&order=ASC&numberposts=-1'); foreach($lastposts as $post) : setup_postdata($post); // somehow remove duplicates titles? ?> <li> <a href="?s=<?php the_title(); ?>&post_type=catalogue"> <?php the_title(); ?> </a> </li> <?php endforeach; ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Get posts – remove duplicate titles from loop’ is closed to new replies.