最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Posts missing on author page

programmeradmin3浏览0评论

I run a news website and was editing the author page PHP. I think I accidentally deleted some code because now no posts show under any of the author pages.

Here is my code:

    <?php if( ! get_theme_mod( 'penci_disable_breadcrumb' ) ): ?>
        <?php
        $yoast_breadcrumb = '';
        if ( function_exists( 'yoast_breadcrumb' ) ) {
            $yoast_breadcrumb = yoast_breadcrumb( '<div class="container penci-breadcrumb">', '</div>', false );
        }

        if( $yoast_breadcrumb ){
            echo $yoast_breadcrumb;
        }else{ ?>
        <div class="container penci-breadcrumb">
            <span><a class="crumb" href="<?php echo esc_url( home_url('/') ); ?>"><?php echo penci_get_setting( 'penci_trans_home' ); ?></a></span><i class="fa fa-angle-right"></i>
            <?php
            echo '<span>';
            echo penci_get_setting( 'penci_trans_author' );
            echo '</span>';
            ?>
        </div>
        <?php } ?>
    <?php endif; ?>

    <div class="container<?php echo esc_attr( $class_layout ); if ( penci_get_setting( 'penci_sidebar_archive' ) ) : ?> penci_sidebar <?php echo esc_attr( $sidebar_position ); ?><?php endif; ?>">
        <div id="main" class="penci-layout-<?php echo esc_attr( $layout_this ); ?><?php if ( get_theme_mod( 'penci_sidebar_sticky' ) ): ?> penci-main-sticky-sidebar<?php endif; ?>">
            <div class="theiaStickySidebar">
                <div class="archive-box">
                    <div class="title-bar">
                        <?php
                        echo '<span>';
                        echo penci_get_setting( 'penci_trans_author' );
                        echo ' </span>';
                        printf( wp_kses ( __( '<h1 class="page-title">%s</h1>', 'soledad' ), penci_allow_html() ), get_userdata( get_query_var('author') )->display_name );
                        ?>
                    </div>
                </div>

                <?php get_template_part( 'inc/templates/about_author' ); ?>

                <?php echo penci_render_google_adsense( 'penci_archive_ad_above' ); ?>

                <?php if ( have_posts() ) : ?>
                    <?php
                    $class_grid_arr = array()
                    ;
                    if( in_array( $layout_this, $class_grid_arr ) ) {
                        echo '<ul class="penci-wrapper-data penci-grid">';
                    }elseif( in_array( $layout_this, array( 'masonry', 'masonry-2' ) ) ) {
                        echo '<div class="penci-wrap-masonry"><div class="penci-wrapper-data masonry penci-masonry">';
                    }elseif( get_theme_mod( 'penci_archive_nav_ajax' ) || get_theme_mod( 'penci_archive_nav_scroll' ) ) {
                        echo '<div class="penci-wrapper-data">';
                    }

                    while ( have_posts() ) : the_post();
                        include( locate_template( 'content-' . $layout_this . '.php' ) );
                    endwhile;

                    if( in_array( $layout_this, $class_grid_arr ) ) {
                        echo '</ul>';
                    }elseif( in_array( $layout_this, array( 'masonry', 'masonry-2' ) ) ) {
                        echo '</div></div>';
                    }elseif( get_theme_mod( 'penci_archive_nav_ajax' ) || get_theme_mod( 'penci_archive_nav_scroll' ) ) {
                        echo '</div>';
                    }

                    penci_soledad_archive_pag_style( $layout_this );
                    ?>
                <?php endif; wp_reset_postdata(); /* End if of the loop */ ?>

                <?php echo penci_render_google_adsense( 'penci_archive_ad_below' ); ?>

            </div>
        </div>

    <?php if ( penci_get_setting( 'penci_sidebar_archive' ) ) : ?><?php get_sidebar(); ?><?php endif; ?>

I run a news website and was editing the author page PHP. I think I accidentally deleted some code because now no posts show under any of the author pages.

Here is my code:

    <?php if( ! get_theme_mod( 'penci_disable_breadcrumb' ) ): ?>
        <?php
        $yoast_breadcrumb = '';
        if ( function_exists( 'yoast_breadcrumb' ) ) {
            $yoast_breadcrumb = yoast_breadcrumb( '<div class="container penci-breadcrumb">', '</div>', false );
        }

        if( $yoast_breadcrumb ){
            echo $yoast_breadcrumb;
        }else{ ?>
        <div class="container penci-breadcrumb">
            <span><a class="crumb" href="<?php echo esc_url( home_url('/') ); ?>"><?php echo penci_get_setting( 'penci_trans_home' ); ?></a></span><i class="fa fa-angle-right"></i>
            <?php
            echo '<span>';
            echo penci_get_setting( 'penci_trans_author' );
            echo '</span>';
            ?>
        </div>
        <?php } ?>
    <?php endif; ?>

    <div class="container<?php echo esc_attr( $class_layout ); if ( penci_get_setting( 'penci_sidebar_archive' ) ) : ?> penci_sidebar <?php echo esc_attr( $sidebar_position ); ?><?php endif; ?>">
        <div id="main" class="penci-layout-<?php echo esc_attr( $layout_this ); ?><?php if ( get_theme_mod( 'penci_sidebar_sticky' ) ): ?> penci-main-sticky-sidebar<?php endif; ?>">
            <div class="theiaStickySidebar">
                <div class="archive-box">
                    <div class="title-bar">
                        <?php
                        echo '<span>';
                        echo penci_get_setting( 'penci_trans_author' );
                        echo ' </span>';
                        printf( wp_kses ( __( '<h1 class="page-title">%s</h1>', 'soledad' ), penci_allow_html() ), get_userdata( get_query_var('author') )->display_name );
                        ?>
                    </div>
                </div>

                <?php get_template_part( 'inc/templates/about_author' ); ?>

                <?php echo penci_render_google_adsense( 'penci_archive_ad_above' ); ?>

                <?php if ( have_posts() ) : ?>
                    <?php
                    $class_grid_arr = array()
                    ;
                    if( in_array( $layout_this, $class_grid_arr ) ) {
                        echo '<ul class="penci-wrapper-data penci-grid">';
                    }elseif( in_array( $layout_this, array( 'masonry', 'masonry-2' ) ) ) {
                        echo '<div class="penci-wrap-masonry"><div class="penci-wrapper-data masonry penci-masonry">';
                    }elseif( get_theme_mod( 'penci_archive_nav_ajax' ) || get_theme_mod( 'penci_archive_nav_scroll' ) ) {
                        echo '<div class="penci-wrapper-data">';
                    }

                    while ( have_posts() ) : the_post();
                        include( locate_template( 'content-' . $layout_this . '.php' ) );
                    endwhile;

                    if( in_array( $layout_this, $class_grid_arr ) ) {
                        echo '</ul>';
                    }elseif( in_array( $layout_this, array( 'masonry', 'masonry-2' ) ) ) {
                        echo '</div></div>';
                    }elseif( get_theme_mod( 'penci_archive_nav_ajax' ) || get_theme_mod( 'penci_archive_nav_scroll' ) ) {
                        echo '</div>';
                    }

                    penci_soledad_archive_pag_style( $layout_this );
                    ?>
                <?php endif; wp_reset_postdata(); /* End if of the loop */ ?>

                <?php echo penci_render_google_adsense( 'penci_archive_ad_below' ); ?>

            </div>
        </div>

    <?php if ( penci_get_setting( 'penci_sidebar_archive' ) ) : ?><?php get_sidebar(); ?><?php endif; ?>
Share Improve this question asked May 8, 2020 at 15:11 Robert TannRobert Tann 1
Add a comment  | 

1 Answer 1

Reset to default 0

It's best not to edit theme files directly, because when you update the theme, your changes are lost. Instead, if you need to change things, create a child theme and you can do whatever you need there.

To restore the previous file you can either download a fresh copy of your theme, or look through your backups.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论