指向作者特定页面的静态登录页面,这些页面包含“实时”内容

时间:2013-05-23 作者:user1255049

我的网站有一个静态登录页,有按钮可以转到Cait的内容或Shannons的内容。每个作者的页面都会有自己的帖子,以及一个包含社交媒体流的部分。这两位作者的内容必须分开。目前,我正在使用标题中的条件标记来处理这个问题,但最终只剩下空白的作者页面。有什么想法可以纠正吗?

标题。php-

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="<?php bloginfo(\'html_type\'); ?>; charset=<?php bloginfo(\'charset\'); ?>" />
    <meta name="generator" content="Wordpress <?php bloginfo(\'version\'); ?>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title><?php bloginfo(\'name\'); ?> <?php wp_title(); ?></title>
    <link rel="pingback" href="<?php bloginfo(\'pingback url\'); ?>" />
    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo(\'rss2_url\'); ?>" />
    <link rel="stylesheet" href="<?php bloginfo(\'stylesheet_url\'); ?>" />
    <link rel="shortcut icon" href="<?php bloginfo(\'stylesheet_directory\'); ?>/favicon.ico" />
    <?php wp_head(); ?>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

</head>

<body>
<div id="container">
    <div id="header">
        <div class="logo">
            <h1><img src="img/caitlogo.png" alt="cait barker logo" /></h1>
        </div><!-- end logo -->
        <nav>
            <ul>
                <li><a href="#">outfit of the day</a></li>
                <li><a href="#">vlog</a></li>
                <li><a href="#">features</a></li>
                <li><a href="#">diy</a></li>
                <li><a href="#">contact</a></li>
            </ul>
        </nav><!-- end nav -->
        <div class="social">
            <ul>
                <li><a href="http://web.stagram.com/n/caitbarkerr/"><img src="img/instagram.png" alt="cait barker instagram" /></a></li>
                <li><a href="http://www.youtube.com/user/caitbarker"><img src="img/youtube.png" alt="cait barker youtube" /></a></li>
                <li><a href="http://www.facebook.com/CaitShannonBarker"><img src="img/facebook.png" alt="cait barker facebook" /></a></li>
                <li><a href="https://twitter.com/caitbarkerr"><img src="img/twitter.png" alt="cait barker twitter" /></a></li>
                <li><a href="#"><img src="img/pinterest.png" alt="cait barker pinterest" /></a></li>
            </ul>
        </div><!-- end social -->
    </div><!-- end header -->

    <div id="streams">
        <div class="vlog-stream">
            <?php
                if (is_author(cait barker)) {
                echo do_shortcode("[ix_show_latest_yt ytid=\'caitbarker\' width=\'280\' height=\'170\' autoplay=\'off\' count_of_videos=\'1\']");
                }
                if (is_author(shannon barker)) {
                echo do_shortcode("[ix_show_latest_yt ytid=\'shannonbarkerr\' width=\'280\' height=\'170\' autoplay=\'off\' count_of_videos=\'1\']");
                }
            ?>
            <p>vlog</p>
        </div><!-- end vlog-stream -->
        <div class="ootd-stream">
            <?php
                if (is_author(cait barker)) {
                $new_query = new WP_Query( \'cat=your_category_id&showposts=2\' );
                if( $new_query->have_posts() ): while( $new_query->have_posts ): $new_query->the_post();

                the_post_thumbnail();

                endwhile;
                endif;
                wp_reset_query();
                ]
                if (is_author(shannon barker)) {
                $new_query = new WP_Query( \'cat=your_category_id&showposts=10\' );
                if( $new_query->have_posts() ): while( $new_query->have_posts ): $new_query->the_post();

                the_post_thumbnail();

                endwhile;
                endif;
                wp_reset_query();
                ]
            ?>
            <p>outfit of the day</p>
        </div><!-- end ootd-stream -->
        <div class="insta-stream">
            <?php
                if (is_author(cait barker)) {
                echo do_shortcode("[instapress userid=\'caitbarkerr\' piccount=\'6\' size=\'73px\']");
                ]
                if (is_author(shannon barker)) {
                echo do_shortcode("[instapress userid=\'shannonbarkerr\' piccount=\'6\' size=\'73px\']");
                ]
            ?> 
            <p>instagram</p>
        </div><!-- end insta-stream -->
    </div><!-- end streams -->
索引。php-

<?php echo get_header();;?>
<?php
    if (is_author(cait barker)) {
    echo get_sidebar(\'cait\');;
    }
    if (is_author(shannon barker)) {
    echo get_sidebar(\'shannon\');;
    }
?>


<div id="blog">
    <div class="preview">
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <div class="post-image">
            <?php echo ravs_get_custom_image( get_post_thumbnail_id () ); ?>
        </div><!-- end post-image -->
        <div class="post">
            <h2><?php the_title() ;?></h2>
            <span class="post-preview">
                <?php the_excerpt(\'read more...\'); ?>
                <?php endwhile; else: ?>

                    <p>Sorry, no posts to list</p>

                <?php endif; ?>
            </span><!-- end post-preivew -->
            <p class="post-meta"><span style="font-family: amatic;">>></span>&nbsp;Posted on <?php the_date(\'M-d-y\'); ?>&nbsp;<span style="font-family: amatic;">>></span>&nbsp;<?php the_tags(\'tags: \', \', \', \'<br />\'); ?></p><!-- end post-meta -->
        </div><!-- end post -->
    </div><!-- end preview -->
</div><!-- end blog -->


<?php get_footer(); ?>

2 个回复
最合适的回答,由SO网友:Ravinder Kumar 整理而成

正如我在标题中看到的代码。php和索引。php看起来很凌乱(因为if 条件)。如果我理解你的问题,那么我会这样做

创建单独的author.php 两位作者的名字都是author-cait.phpauthor-shannons.php

  • 像这样给出链接http://www.yousite.com/author/cait/ 到静态登录页上的按钮。当用户点击这个时,它会带他到作者的特定author.php 如果存在,创建custom header.php 两位作者的姓名如下header-cait.phpheader-shannons.phpcustom sidebar.php 两位作者的姓名如下sidebar-cait.phpsidebar-shannons.phpauthor-cait.php 只包含cait的条件、标题和侧栏
  • 它使您的代码看起来漂亮、易于管理,避免了if 条件

    SO网友:s_ha_dum

    你没有声明两个贴子索引页,无论如何我都不知道。如果有办法的话,考虑到你的其他条件,我仍然认为接下来的是更好的解决方案。

    我想你可以template_redirect 并根据作者加载不同的模板,但更简洁的解决方案是create a new post type 对于每个作者。每个类型,以及每个作者,都有自己的索引页,您可以使用内置的templating system to format the pages.

    两位作者可以共享标签和类别,您可以create new taxonomies for each author and keep those separated, 或者两者兼而有之——分享一些,保持另一些与众不同。

    你也可以create sidebars specific to the post type, 因此是针对作者的。

    我认为这涵盖了你提到的问题。

    结束

    相关推荐

    Change order of posts

    我最近发了一篇帖子,没有正确解释自己!再来一次,但要有更好的解释。我需要“选择选项”更改query\\u帖子的顺序。我当前的代码是:<select> <option selected=\"selected\">Select order of posts</option> <option>Highest price</option><!-- hypercart_meta_price \"order=DESC\