[wp-hackers] Custom post types and wp_get_archives

Fong Li Heng fonglh at gmail.com
Wed Jul 4 02:27:16 UTC 2012


Hi Aero,

I modified the default widget to take a custom post type parameter, and
also turned it into a jQuery accordion so the list is more manageable. I
wrote a series of blog posts about it, you can start from
https://wpadventures.wordpress.com/2011/02/14/custom-post-type-archives-2/

Sorry it's a little messy and I dumped everything into my theme's
functions.php file. Would definitely be better to implement it as a plugin
but I hadn't figured out the template redirects at that time. Hope this
helps you get started.


On Wed, Jul 4, 2012 at 5:22 AM, Mike Little <wordpress at zed1.com> wrote:

> On 3 July 2012 21:10, Aero Maxx <aero.maxx.d at gmail.com> wrote:
>
> >  Hi Mike,
> >
> > I have been trying to work out how to use the code that you wrote, as I
> > like that it makes the recent posts widget work, but it seems to mess
> with
> > my blog posts only page in that it shows posts from my custom post type
> > aswell as posts from the blog, have tried using !is_page ( array (
> 'Blog',
> > 'blog' ) ) but it doesn't seem to change anything.
> >
> >
> Sorry, I thought that was what you wanted. When you are talking about
> archives, do you just mean the archives widget? I misunderstood your
> requirements.
>
> Do you have any ideas as to what I could do ?
> >
> >
> You need to remove the "cpt_add_to_posts" code.
>
>
>
> > Also do you or anyone know how I could get a list based archive on my
> side
> > bar for my custom post type, but to only show the last 6 months, as its
> > fairly long list otherwise.
> >
> > Have decided to keep the blog posts and the custom post type archives
> > seperate.
> >
> >
>
> For your other issue, you will either have to use a plugin that will list
> CPT archives, or write some code to duplicate the archives widget
> functionality for your CPT, with the added functionality to restrict the
> number of entries.
>
> Mike
> --
> Mike Little
> http://zed1.com/
> _______________________________________________
> 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