个性化阅读
专注于IT技术分析

WordPress Content.php文件

我正在尝试删除此博客文章wordpress模板顶部的精选图片。作者做得很好, 但留下的博客却很糟糕。我仍然需要精选图片作为缩略图, 但是在此页面上真是一团糟。我想将视频放在横幅上方。我拿出一堆东西弄乱了。我研究了如何使用类函数, 另一种解决方案是关于编辑single.php文件。浏览了single.php文件之后, 我得出结论, 我想要删除的所有内容似乎都位于一个名为content.php的文件中。

因此, 这里是链接:http://beautynetworkeffect.com/ground-zero-hong-kong-fashion-extravaganza-2015-fashion-one/

这是代码:

    <?php
/**
 * The default template for displaying content
 *
 * Used for both single and index/archive/search.
 *
 * @package WordPress
 * @subpackage Javo_Directory
 * @since Javo Themes 1.0
 */

global $wp_query;
$javo_author    = new WP_User( get_the_author_meta( 'ID' ) ); ?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?> class="row">
    <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
    <div class="featured-post">
        <?php _e( 'Featured post', 'javo_fr' ); ?>
    </div>
    <?php endif; ?>

    <div class="row">

        <div class="col-md-12">
            <header class="entry-header text-center">
                <?php the_post_thumbnail('full', Array('class' => 'img-responsive')); ?>
                <div class="label-ribbon-row {f}">
                    <div class="label-info-ribbon-row-wrapper">
                        <div class="label-info-ribbon-row">
                            <div class="ribbons" id="ribbon-15">
                                <div class="ribbon-wrap">
                                    <div class="content">
                                        <div class="ribbon">
                                            <span class="ribbon-span">
                                                <?php echo get_the_date( 'M d Y'); ?>
                                            </span>
                                        </div>
                                    </div><!-- /.content -->
                                </div><!-- /.ribbon-wrap -->
                            </div><!-- /.ribbons -->
                        </div><!-- /.label-info-ribbon -->
                    </div><!-- /.ribbon-wrapper -->
                </div><!-- /.label-ribbon -->
            </header><!-- .entry-header -->
        </div><!-- col-md-4 -->

    </div>
    <div class="row entry-author-info-wrap">
        <div class="col-md-2 col-xs-2 entry-author-image">
            <a>
                <div class="javo-thb" style="width:80px; height:80px; background-image:url('<?php echo apply_filters( 'javo_load_attach_image', $javo_author->avatar );?>');"></div>
            </a>
        </div>
        <div class="col-md-10 col-xs-10 entry-author-meta-wrap">
            <div class="entry-author-name"><?php echo $javo_author->display_name; ?></div>
            <div class="entry-author-social">
                <div class="entry-author-category">
                    <i class="fa fa-bookmark-o"></i>
                    <?php the_category( ', ' ); ?>
                </div>
                <?php if( comments_open() ) : ?>
                    <div class="pull-left" style="margin:0 10px;">
                        <span class="separator">/</span>
                    </div>
                    <div class="entry-author-comment">
                        <i class="fa fa-comments-o"></i>
                        <?php
                        comments_popup_link(
                            __( '0 Comment', 'javo_fr' )
                            , __( '1 Comment', 'javo_fr' )
                            , __( '% Comments', 'javo_fr' )
                        ); ?>
                    </div>
                <?php endif; // comments_open() ?>
            </div>
        </div>
    </div><!--row entry-author-info-wrap-->
    <div class="row entry-description-wrap">
        <div class="col-md-12 entry-description">
            <?php if ( is_single() ) : ?>
                <h1 class="entry-title"><?php the_title(); ?></h1>
                <div class="single-post-meta row">
                    <div class="col-md-10 post-meta-infor">

                    </div> <!-- col-md-10 -->

                    <div class="col-md-2 text-right post-social">
                        <span class="javo-sns-wrap social-wrap">
                            <i class="sns-facebook" data-title="<?php the_title();?>" data-url="<?php the_permalink();?>">
                                <a class="facebook javo-tooltip" title="<?php _e('Share Facebook', 'javo_fr');?>"></a>
                            </i>
                            <i class="sns-twitter" data-title="<?php the_title();?>" data-url="<?php the_permalink();?>">
                                <a class="twitter javo-tooltip" title="<?php _e('Share Twitter', 'javo_fr');?>"></a>
                            </i>
                        </span>
                    </div> <!-- col-md-2-->
                </div> <!-- single-post-meta -->

            <?php else : ?>
                <h1 class="entry-title">
                    <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
                </h1>
            <?php endif; // is_single() ?>
            <?php if ( is_search() ) : // Only display Excerpts for Search ?>
                <div class="entry-summary">
                    <?php the_excerpt(); ?>
                </div><!-- .entry-summary -->
            <?php else : ?>
                <div class="entry-content">
                    <?php
                    if( is_category() )
                    {
                        printf('<a href="%s">%s</a>', get_permalink(), javo_str_cut( get_the_excerpt(), 300));
                    }else{
                        the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'javo_fr' ) );
                    } ?>

                    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'javo_fr' ), 'after' => '</div>' ) ); ?>
                </div><!-- .entry-content -->
            <?php endif; ?>
        </div><!-- 12 Columns Close -->
    </div><!-- Row Close -->
    <footer class="entry-meta">
        <div class="inner-footer">
            <div class="inner-footer-more">
                <a href="<?php the_permalink(); ?>">
                    <?php _e( "more", 'javo_fr' ); ?>
                </a>
            </div>
        <?php //javo_drt_entry_meta(); ?>
        <?php edit_post_link( "<i class=\"fa fa-cog\"></i>" . __( 'Edit', 'javo_fr' ), '<span class="edit-link">', '</span>' ); ?>
        <?php if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?>
            <div class="author-info">
                <div class="author-avatar">
                    <?php
                    /** This filter is documented in author.php */
                    $author_bio_avatar_size = apply_filters( 'javo_drt_author_bio_avatar_size', 68 );
                    echo get_avatar( get_the_author_meta( 'user_email' ), $author_bio_avatar_size );
                    ?>
                </div><!-- .author-avatar -->
                <div class="author-description">
                    <h2><?php printf( __( 'About %s', 'javo_fr' ), get_the_author() ); ?></h2>
                    <p><?php the_author_meta( 'description' ); ?></p>
                    <div class="author-link">
                        <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author">
                            <?php printf( __( 'View all posts by %s <span class="meta-nav">&rarr;</span>', 'javo_fr' ), get_the_author() ); ?>
                        </a>
                    </div><!-- .author-link -->
                </div><!-- .author-description -->
            </div><!-- .author-info -->
        <?php endif; ?>
        </div>
    </footer><!-- .entry-meta -->

</article><!-- #post -->

#1


要仅删除特色图片, 你必须删除或注释” the_post_thumbnail”行:

<?php // the_post_thumbnail('full', Array('class' => 'img-responsive')); ?>

要删除特色图像和日期功能区, 请删除所有这些行:

<div class="row">

    <div class="col-md-12">
        <header class="entry-header text-center">
            <?php the_post_thumbnail('full', Array('class' => 'img-responsive')); ?>
            <div class="label-ribbon-row {f}">
                <div class="label-info-ribbon-row-wrapper">
                    <div class="label-info-ribbon-row">
                        <div class="ribbons" id="ribbon-15">
                            <div class="ribbon-wrap">
                                <div class="content">
                                    <div class="ribbon">
                                        <span class="ribbon-span">
                                            <?php echo get_the_date( 'M d Y'); ?>
                                        </span>
                                    </div>
                                </div><!-- /.content -->
                            </div><!-- /.ribbon-wrap -->
                        </div><!-- /.ribbons -->
                    </div><!-- /.label-info-ribbon -->
                </div><!-- /.ribbon-wrapper -->
            </div><!-- /.label-ribbon -->
        </header><!-- .entry-header -->
    </div><!-- col-md-4 -->

</div>

请记住, 将主题更新为新版本时, 所有更改都将被覆盖。避免这种情况的一个不错的选择是创建子主题, 这是修改现有主题的推荐方法。可以在以下位置找到更多信息:https://codex.wordpress.org/Child_Themes

测试它, 让我知道你是否有任何问题。

问候。


#2


我将在此处添加一些内容, 因为它对那些愿意了解Wordpress文件Content.php的人有所帮助。

此文件是wordpress在wordpress上生成帖子内容的方式。

此代码很容易理解

if ( is_single() ) {
        the_title( '<h1 class="entry-title">', '</h1>' );
    } elseif ( is_front_page() && is_home() ) {
        the_title( '<h3 class="123123"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
    } else {
        the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' );
    }
    ?>

它在所请求页面的基础上显示不同的内容。

赞(0)
未经允许不得转载:srcmini » WordPress Content.php文件

评论 抢沙发

评论前必须登录!