• Hi,

    I’ve been trying to implement the wp_get_post_type_archives() into my template but with no success. The documentation only provided this:

    I’ve made a new function ‘wp_get_post_type_archives’ that works basically the same way as the ‘wp_get_archives’ function from WordPress. Actually it uses that function to get all the data and formatting. I only had to make this wrapper function to fix the links that link to these archives, because WordPress sadly didn’t have enough hooks in that function. This function has two parameters:

    * $post_type – string with post type rewrite slug to whom do you want to get archives from. You can also supply ‘all’ as a value – that will return links to archives for ALL the custom post types. The only thing is – you have to make the homepage to include all the post types if you want this to work (to support ‘all’ value, rest will work perfectly).
    * $args – the same arguments as you would pass to ‘wp_get_archives’ function.

    I’ve tried everything, but it seems that it only shows the default post type, not the custom post types post.

    I’ve tried:
    <?php wp_get_post_type_archives('post_type=blogs&type=monthly&show_post_count=true'); ?>
    and

    <?php wp_get_post_type_archives('post_type=blogs','type=monthly&show_post_count=true'); ?>'
    and also

    <?php $post_type = array(‘post_type’ => ‘blogs’);
    $args = array(‘type’ => ‘monthly’, ‘limit’ => 12, ‘show_post_count’ => true);
    wp_get_post_type_archives(‘post_type=blogs&type=monthly&show_post_count=true’); ?>`

    I’m not sure what I’m doing wrong as I am new with PHP.

    A documentation with example codes would be great.

    Thanks in advance.

    http://wordpress.org/extend/plugins/custom-post-type-archives/

Viewing 1 replies (of 1 total)
  • Plugin Author rATRIJS

    (@ratrijs)

    Hi che-mat!

    The first argument should be the rewrite slug for your custom post type. In your case it seems to be ‘blogs’. The second argument is the same as what you would use in wp_get_archives() function.

    To sum up -> you would use this function like this:

    wp_get_post_type_archives('blogs', array('type' => 'monthly', 'show_post_count' => true);

    If that doesn’t work, then try using ‘blog’ in stead of ‘blogs’.

    Hope that this helps and I will try to put some examples in Faq.

    Thanks.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Custom Post Type Archives] How to use wp_get_post_type_archives() function’ is closed to new replies.