Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter jmgchengfreemight

    (@jmgchengfreemight)

    done solving my problem with reference of:
    http://www.danielauener.com/extend-wp_query-with-custom-parameters/

    function.php

    function archive_dd_pre_get( $query )
    {
    	if ( isset($query->query_vars['limit_column']) && $query->query_vars['limit_column'] == 'idtitledatestatustype' )
    	{
    		$query->limit_column = $query->query_vars['limit_column'];
    	}
    }
    add_action( 'pre_get_posts', 'archive_dd_pre_get' );
    function archive_dd_filter( $fields, &$wp_query )
    {
        global $wpdb;
    	if( $wp_query->query_vars['limit_column'] == 'idtitledatestatustype' ) {
    		$fields = "$wpdb->posts.post_date";
        }
        return $fields;
    }
    add_filter('posts_fields', 'archive_dd_filter', 10, 2);

    somewhere.php
    $o_query_result = new WP_Query( array( 'category_name' => 'cat 1', 'posts_per_page' => -1, 'post_status' => 'publish', 'limit_column' => 'idtitledatestatustype' ) );

Viewing 1 replies (of 1 total)