• After the upgrade to 3.4:
    My website seems to be returning a 404 page when I navigate to the next set of posts on my homepage. I have a total of 12posts – 9per page.

    I have tried the following:
    – Change permalinks to default, then back to “month and name” structure

    – added the code below to my functions file in my theme folder as some forum members were suggesting

    function my_post_queries( $query ) {
    // not an admin page and it is the main query
    if (!is_admin() && $query->is_main_query()){
    if(is_home()){
    $query->set(‘posts_per_page’, 1);
    }
    }
    }
    add_action( ‘pre_get_posts’, ‘my_post_queries’ );

    I thank you for your help in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter sgronjaer

    (@sgronjaer)

    I solved the problem by adding the code below to my functions.php file in my theme folder

    function my_query_for_homepage( $query ) {
        if( $query->is_main_query() && $query->is_home() ) {
            $query->set( 'post_type', array( 'type_i_want_diplayed' ) );
        }
    }
    add_action( 'pre_get_posts', 'my_query_for_homepage' );

    I assume this a theme related problem.

    Does it work when the permalink settings are default?
    What theme are you using?
    URL, so we can see what’s happening?
    Tried it without active plugins, or with the default theme?
    The code in functions.php should be removed, as it certainly doesn’t solve such problems. It just sets the number of posts on the home page to 1.

    Thread Starter sgronjaer

    (@sgronjaer)

    Thank you for your help.
    I was able to solve the problem by adding this code to the functions file:

    function my_query_for_homepage( $query ) {
        if( $query->is_main_query() && $query->is_home() ) {
            $query->set( 'post_type', array( 'type_i_want_diplayed' ) );
        }
    }
    add_action( 'pre_get_posts', 'my_query_for_homepage' );

    This is what was in my theme index file:

    <?php
      $type = 'girls';
      $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
      $args=array(
        'post_type' => $type,
        'post_status' => 'publish',
        'paged' => $paged,
        //'posts_per_page' => 1,
        'caller_get_posts'=> 1
      );
      $temp = $wp_query;  // assign original query to temp variable for later use
      $wp_query = null;
      $wp_query = new WP_Query();
      $wp_query->query($args);
    ?>

    Apparently, the theme is not coded so well because it is creating a new query rather than modifying the query.

    If there is a theme setting that alters the number of posts on the home page, as opposed to the default setting in the core options, then try to set this number to the same value.

    It may be that your theme is doing something wrong, as using query_posts() in a template. This is a wrong way of doing things. You may use your code in functions.php until you get an update of your theme, but set the value to the number you want (9), not 1.

    Thread Starter sgronjaer

    (@sgronjaer)

    no settings in the theme for the number of posts.
    I will contact the themes support team.

    the them i am using is the escort theme from
    http://www.bangthemes.com/

    They do have a new version. Will contact them and check if the new version will solve the problem.

    Anyways, thank you for your time.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘404 Page 2 wordpress 3.4’ is closed to new replies.