所以我有一个网站,在那里我使用了作者。php页面,以便显示单个用户的配置文件页面。。然后,url看起来像:http://mydomain.com/author/test/
我想做的是拥有它,这样我就可以在其中添加每个用户通用的子页面,即:http://mydomain.com/author/test/liked-posts/ 在那里,我可以添加用户喜欢的所有帖子,即:喜欢的帖子。php
是否有一个地方我应该告诉这个结构的URL重定向到一个特定的文件?我该怎么做?
这是我用来查询帖子的完整代码:
<?php
/**
* Template Name: Posts liked by Author
*
* for a child theme of Twenty_Twelve
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php
$author = get_user_by( \'slug\', get_query_var( \'author_name\' ) );
$post_ids = $wpdb->get_col( "SELECT DISTINCT post_id FROM {$wpdb->prefix}wti_like_post WHERE user_id = {$author->ID}" );
if( strpos( $wp_query->query_vars[\'liked-posts\'] ,\'page\') !== false ) {
$paged = substr( $wp_query->query_vars[\'liked-posts\'], 5 );
}
$args = array(
\'posts_per_page\' => 4,
\'paged\' => $paged,
\'order\' => \'ASC\',
\'post__in\' => $post_ids
);
$wp_query = new WP_Query();
$wp_query->query( $args ); ? >
<?php 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\' ); ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( \'Nothing Found\', \'twentytwelve\' ); ?></h1>
</header>
<div class="entry-content">
<p><?php _e( \'Apologies, but no results were found. Perhaps searching will help find a related post.\', \'twentytwelve\' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; wp_reset_postdata(); ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>