[wp-hackers] Getting every page ID, URL, and Title on site
Barry Carlyon
barry at barrycarlyon.co.uk
Thu Apr 7 18:37:49 UTC 2011
Is it not just a matter, off the top of my head.
Of doing a standard query to get all the ID's of post type published
Or just doing a query to get the relevant columns from the database (where the post is published)
Depending on what the end content is for
--------------------------------
Barry Carlyon
Freelance Web Developer
Freelance Lighting/AV Engineer
http://barrycarlyon.co.uk
mobile: 07729 048 443
skype: barrycarlyon
email: barry at barrycarlyon.co.uk
msn: barry at barrycarlyon.co.uk
On 7 Apr 2011, at 19:35, Philip Walton wrote:
> Robert, I have a plugin that does a similar thing to what you're asking:
> PW_Archives <http://wordpress.org/extend/plugins/pw-archives/> (to toot my
> own horn). You can probably look at the source, specifically the queries I'm
> doing, and customize them for your purposes.
>
> I had the same problem you're having because in order to get the permalink
> of a post via a WordPress function, you have to download its content from
> the database as well, which seems like an incredible waste to me since some
> of my sites have 1000+ posts with tons of content.
>
> My solution was kind of hackish, but basically I'm doing a custom query for
> all the posts and creating a fake post object (excluding content and other
> unnecessary stuff), so get_permalink doesn't run an additional query. The
> only problem with this is if the user has some crazy permalink structure
> that requires this extra post info, it'll break.
>
> I did some testing on my site and it reduced page load from like 3 seconds
> to less than a second.
>
> Hope that helps.
>
>
>
> On Thu, Apr 7, 2011 at 11:25 AM, Robert Lusby <nanogwp at gmail.com> wrote:
>
>> Any ideas on the cleanest way to list every page (inc pages, posts, and
>> custom post types) in a site?
>>
>> I only require ID, Title and Permalink(URL) for each page.
>>
>> Seems so simple, but running a loop seems so excessive as I don't require
>> the page content at all ... and get_pages only works on pages (not custom
>> post types) (plus also returns content).
>>
>> Any suggestions for the least intensive way to simply get these three
>> items?
>>
>> Thanks,
>> Rob
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
> --
> Philip Walton
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
More information about the wp-hackers
mailing list