0

I have a page named "calientes" with a complex loop that's working perfectly. This page is located at domain.com/calientes/. Now I need to use this page as the home page, so I went to "Settings -> Reading" and chose that page as static page.

The problem now is that the pagination no longer works. On the actual page it shows like domain.com/calientes/page/2 and it work perfectly! but now it shows as domain.com/page/2/ when i really want to go to domain.com/calientes/page/2

I didn't do any other changes, just chose that page as front page basically.

What can i do to made my pagination call domain.com/calientes/page/2?

This is my query on my page "Calientes" :

$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;

$args = array(
  'posts_per_page' => 9,
  'paged' => $paged,
  'meta_query' => array(
     array(
       'key' => '_wti_like_count',
       'value' => 10,
       'compare' => '>=',
       'type' => 'numeric'
     )
  )
);

$wp_query = new WP_Query();
$wp_query->query( $args );

if( have_posts() ) : ?>

<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

<?php get_template_part( 'content', get_post_format() ); ?>
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>

<?php twentytwelve_content_nav( 'nav-below' ); ?>
3
  • What is your permalink structure? does it contain a trailing slash?
    – Milo
    Commented Oct 17, 2013 at 15:25
  • This is my Permalink Settings : I have the Post Name Activated 127.0.0.1:4001/wordpress/sample-post ... /wordpress/ is my base folder because i'm using instantwp to build my website before uploaded it to my public server!
    – Oscar
    Commented Oct 17, 2013 at 15:32
  • If your permalink structure contains a trailing slash, WordPress should enforce the slash on all URLs. The behavior of your front page is correct, the behavior of your calientes page is the one that is wrong.
    – Milo
    Commented Oct 17, 2013 at 15:37

1 Answer 1

0

This is perfectly normal. When you set a page as front page WordPress thinks that you want to use the home url for it.

Said that, the url for your calientes page will be your home url (http://domain.com). Now, front pages are not intened to use pagination, so if you put /page/{number} on a fron page it is considered the 'page' query var, not the 'paged', so if you have it as fron page you have to use:

$var = is_front_page() ? 'page' : 'paged';
$paged = ( get_query_var($var) ) ? get_query_var($var) : 1;

However, if you want the url stay http://domain.com/calientes/ (this will became your home url) you need a redirect and do not set 'Calientes' page as home page.

add_action('init', 'calientes_home');

function calientes_home() {
   $fullurl = add_query_arg( array() );
   $url = explode('?', $fullurl);
   $parts = array_filter( explode('/', trim($url[0], '/') ) );
   if ( $parts[0] == 'page' && is_numeric($parts[1]) ) {
     wp_redirect( home_url('/calientes/page/' . $parts[1] ), 301 );
     exit();
   } elseif( $parts === array() ) {
     wp_redirect( home_url('/calientes/'), 301 );
     exit();
   }
}
4
  • Lets say that i want domain.com/calientes to be my home page and i want my url stay domain.com and when i hit next on my pagination im going to be able to go to domain.com/calientes/page/2 ... just like 9gag.com does.. their homepage its 9gag.com/hot and their domain stay 9gag.com it only shows 9gag.com/hot if you click on the menu Hot to go to the Hot's page
    – Oscar
    Commented Oct 17, 2013 at 16:34
  • Check out this Example: Go to lostrolls.com and go all the way down to their pagination where it says "Mayores" if you hit that button their pagination will take you to lostrolls.com/hot/2 because their home page is actually ( lostrolls.com/hot "Hot page" ) and their homepage stay lostrolls.com. That's exactly what i want!
    – Oscar
    Commented Oct 17, 2013 at 16:46
  • That sites are not using WordPress ;) However is something doable in Wordpress too, but unfortunely I have to go now... hoping someone else can help you.. @Oscar
    – gmazzap
    Commented Oct 17, 2013 at 17:19
  • Please help me out!
    – Oscar
    Commented Oct 17, 2013 at 18:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.