• jaseemts

    (@cooljaz124)


    Hi,

    First of all, Big thanks for the plugin πŸ™‚

    I am trying to use the plugin shortcode at 3 different instances in the same page. Each instance need to list the post according to particular “post type”.

    I see, in your code the default post-type as “post”. Is it possible to pass parameter to the plugin ?

    May be a shortcode with argument like below is what we need:

    [cleanarchivesreloaded(‘post-type-1’)]
    [cleanarchivesreloaded(‘post-type-2’)]

    Accordingly, the query on Line number 217 in the plugin , the value of post_type should get replaced with “post-type-1” or “post-type-2”.

    // A direct query is used instead of get_posts() for memory reasons
    		$rawposts = $wpdb->get_results( "SELECT ID, post_date, post_date_gmt, comment_status, comment_count FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND post_password = ''" );

    Or if you have another solution, please do let us know.

    Many thanks again
    Jaz

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Alex Mills

    (@viper007bond)

    Yes, it’s possible but it’d require a little more work than you described and I’m really busy at the moment.

    I’ll add it when I have some free time though.

    Thread Starter jaseemts

    (@cooljaz124)

    Thats great, Alex πŸ™‚

    As for now, I have achieved the same with some really bad code πŸ™‚
    http://pastebin.com/sYRTFuZr

    Added an extra parameter “posttype” in shortcodes.

    [cleanarchivesreloaded posttype=”animation”]

    Thread Starter jaseemts

    (@cooljaz124)

    As I have used

    [cleanarchivesreloaded posttype=”animation”]
    [cleanarchivesreloaded posttype=”madeonipad”] and
    [cleanarchivesreloaded posttype=”posts”]

    – all in the same page, the cache stores the first query and displays the same archives (of animation post-type) at all the 3 places.

    In order to solve this, I just removed

    // If we have a cached copy of the filtered posts array, use that instead
    		// if ( $posts = wp_cache_get( 'posts', 'clean-archives-reloaded' ) )
    		//	return $posts;

    PS: I’m so sorry about the bad coding practise, just letting anyone know there is one odd way to implement this.

    Plugin Contributor Alex Mills

    (@viper007bond)

    Yes, doing it with proper caching is why it’s a little more complicated than you described. It’s just a matter of including the post type in the cache key though and making CleanArchivesReloaded::GetPosts() accept a post type parameter. πŸ™‚

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Clean Archives Reloaded] Altering "Post Type" in Query by passing parameters ?’ is closed to new replies.