Thread Starter
joynic
(@joynic)
@keesiemeijer thank you very much:)
Using your code, I created a “faves” page for each user, it display the contents of the user’s favorite, the following link is working properly:
http://mydomain.com/user/xxx/faves/
but page 2 is broken, and return 404
http://mydomain.com/user/xxx/faves/page/2/
Here is my code…
<?php $favespage = get_query_var('faves'); if($favespage == 'faves' ) : ?>
<?php $user = get_user_by( 'slug', get_query_var( 'author_name' ) );
$user_id = $user->ID;
$bookmarked = get_user_meta( $user_id, 'i_bookmarked_topics', true );
if ( !is_array( $bookmarked) )
$bookmarked = array(); if ( $bm_query = new WP_Query( array( 'post__in' => $bookmarked,'posts_per_page' => 2, 'paged' => $paged ,'post_type' => array( 'post', 'topic', 'goods' ) ) );
if ( $bm_query->have_posts() );
?>
<?php while ( $bm_query->have_posts() ) : $bm_query->the_post(); ?>
...............
<?php if (will_paginate()): ?>
<div class="navigation">
<?php wp_pagenavi(); ?>
</div>
<?php endif; ?>
<?php endif; ?>
You’ll need to add a rule for the paged pages as well. Here is an example for http://mydomain.com/author/xxx/settings/:
$options = array(
'rules' => array(
// add rewrite rules
// rule for feeds
// 'author/([^/]+)/(settings)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&settings=$matches[2]&feed=$matches[3]',
// 'author/([^/]+)/(settings)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&settings=$matches[2]&feed=$matches[3]',
// paged rewrite rule
'author/([^/]+)/(settings)/page/?([0-9]{1,})/?$' => 'index.php?author_name=$matches[1]&settings=$matches[2]&paged=$matches[3]',
'author/([^/]+)/(settings)/?$' => 'index.php?author_name=$matches[1]&settings=$matches[2]'
),
// add query vars
'query_vars' => array( 'settings' )
);
$add_rewrite_rules = new Refactord_add_rewrite_rules( $options );
keesiemeijer, Thank you for posting such helpful replies.
I am so far successful with my rewrite, but I am having a problem checking if I am on the normal author page or the Author Settings page.
I’m using this snippet in my author.php file:
<?php
$settingspage = get_query_var('settings');
if($settingspage == 'settings' ) {
echo "show author settings here";
} else {
echo "show normal author archive page here";
}
?>
Even when I’m on the /author-name/settings page it doesn’t echo “show author settings here” like it should. Wondering if you have had similar problems or know of solution. Thank you