Grow your CSS skills. Land your dream job.

Network wordpress site with custom query issue.

  • # February 28, 2013 at 2:43 pm

    I have a custom query for my network site home page that pulls in all the recent post of the all the blogs. WordPress realizes that I don’t have post for that specific blog so after the first page all my additional pages return 404 but the query is still displayed. The root cause is the wp_class.php function handle_404 (). Does anyone have a work around that might assist with my situation. Or how do I overwrite the wp_query to use my query temporary for that page.

    function get_eh_all_grp_recent_post($blog_list){
    global $wpdb;
    $other_sqlstr = ”;
    $limitstr = ”;
    $uni = ”;

    foreach ($blog_list AS $blog) {
    if ($other_sqlstr != ”)
    $uni = ‘ union all ‘;;
    if($blog == 1) {
    $other_sqlstr .= $uni . ” (SELECT “.$blog.” as blog_id, id, post_date from wp_posts where wp_posts.post_status = ‘publish’ and wp_posts.post_type = ‘post’ and wp_posts.post_title <> ‘”.__(‘Hello world!’).”‘)”;
    }
    else {
    $other_sqlstr .= $uni . ” (SELECT “.$blog.” as blog_id, id, post_date from wp_”.$blog.”_posts where wp_”.$blog.”_posts.post_status = ‘publish’ and wp_”.$blog.”_posts.post_type = ‘post’ and wp_”.$blog.”_posts.post_title <> ‘”.__(‘Hello world!’).”‘ )”;
    }
    }

    //$limit = ‘ LIMIT ‘.$start_page.’, 10′;
    $other_sqlstr .= ” ORDER BY post_date desc “;// . $limit;

    $grp_recent_posts = $wpdb->get_results($other_sqlstr, ARRAY_A);
    //echo $wpdb->print_error();

    return $grp_recent_posts;
    }

    # March 4, 2013 at 4:59 pm

    I am now using wp_multisite_query in hopes to solve the issue but I am still getting a 404 error on page 2.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".