WordPress.org

Ready to get started?Download WordPress

Forums

Custom type pagination 404 after page 1 (1 post)

  1. croissantlab
    Member
    Posted 3 years ago #

    Hi, I could see that this problem has been on lot of post, but all the solution that have been posted didn't work for me. I need to finish this project for a client by the end of this week and I am ready to pay someone to solve this problem..Here is my code :

    $search_propertytype = $_GET['property_type'];
     $search_buyorrent = $_GET['property_buyorrent'];
    
    $_ids = array();
    function getIds( $query ) {
        global $wpdb;
    
        $searchresults = $wpdb->get_results($query, ARRAY_A);
        if ( !empty ($searchresults) ) {
            foreach( $searchresults as $_post ) {
                $tmp[] = $_post['ID'];
            }
        }
    
        return $tmp;
    
    }
    
    global $wpdb;
    
    $query ="SELECT p.* FROM $wpdb->posts p WHERE p.post_type = 'listing' AND p.post_status = 'publish'";
    		$all = getIds( $query );
    		$_ids = ( !empty($all) ? ( !empty($_ids) ? array_intersect( $_ids, $all) : $all ) : "" );
    
    if ($search_buyorrent != "") {
    
    		$query = "SELECT p.* FROM $wpdb->posts p, $wpdb->postmeta p1
    				WHERE p.ID = p1.post_id AND p1.meta_key = 'rob_value' AND p1.meta_value = '$search_buyorrent'";
    		$spm = getIds( $query );
    
    		$_ids = ( !empty($spm) ? ( !empty($_ids) ? array_intersect( $_ids, $spm) : "" ) : "" );
    
    }
    
    if($search_propertytype != '')
    {
        $query ="SELECT p.* FROM $wpdb->posts p, $wpdb->postmeta p1
                WHERE p.ID = p1.post_id AND p1.meta_key='propertytype_value' AND p1.meta_value='$search_propertytype'";
        $sptt = getIds( $query );
    
        $_ids = ( !empty($sptt) ? ( !empty($_ids) ? array_intersect( $_ids, $sptt) : "" ) : "" );
    }
    
    	global $wp_query;
    	wp_reset_query();
    
    	$paged = get_query_var('paged') ? get_query_var('paged') : 1;
    
        $wpq = array ('post_type' => 'listing', 'meta_key' => $metakey, 'orderby' => $orderby, 'order' => $order, 'post__in' => $_ids,  'post_status' => 'publish', 'paged' => get_query_var( 'paged' ), 'posts_per_page' => 1 );
    
    $query = $wpq;
    
    $wp_query = new WP_Query($query);
    
    if($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();

    Any help will be really appreciate.

    Thanks a lot in advance

Topic Closed

This topic has been closed to new replies.

About this Topic