dqoqnmb163241 2019-03-22 03:45
浏览 172

Wordpress - 如何在每个页面上显示标题?

I'm working on a Wordpress site and I have a header image on the homepage. It's only showing up on the homepage but I need it to show on every page. I found this code in the header.php file which I believe needs to be changed, but I'm not very familiar with php.

This is the code for the header image in the header.php file:

<?php $disable_page_title = get_post_meta( get_the_ID(), 'minimal_portfolio_page_title', true ); 
if( $disable_page_title !== 'on' ): ?>
    <?php if( !is_front_page()):  ?>
        <section class="page-header jumbotron <?php if ( get_header_image() ) : ?>bg-image<?php endif; ?>"  <?php if ( get_header_image() ) : ?> style="background-image:url('<?php echo esc_url( get_header_image() ); ?>');" <?php endif; ?>>
        <?php if ( get_header_image() ) : ?><span class="bg-overlay"></span><?php endif; ?>

                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="title-wrap">
                                <?php if( is_page() || is_single() ){ ?>
                                        <h2 class="page-title"><?php echo esc_html( get_the_title() ); ?></h2>

                                    <?php } elseif( is_search() ){ ?>
                                    <?php /* translators: %s: search term */
                                        $page_title = sprintf( esc_html__( 'Search Results for: %s', 'minimal-portfolio' ),  get_search_query() ); 
                                    ?>
                                    <h2 class="page-title"><?php echo esc_html( $page_title ); ?></h2>

                                    <?php }elseif( is_404() ){ ?>

                                    <h2 class="page-title"><?php echo esc_html( 'Page Not Found: 404', 'minimal-portfolio' ); ?></h2>

                                    <?php }elseif( is_home() ){ ?>

                                    <h2 class="page-title"><?php single_post_title(); ?></h2>

                                    <?php } else{

                                        the_archive_title( '<h2 class="page-title">', '</h2>' );
                                    }

                                    if( $minimal_portfolio_breadcrumb_status ):
                                        minimal_portfolio_breadcrumbs();
                                    endif;
                                ?>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        <?php endif;
    endif; ?>

Thank you!

Edit: This is how it shows on all pages but the home page. But I would like it to show the full header instead of only a section of it with the page title.

Header

This is the home page, where it shows the full header and how I'd like it to show on every page instead of how it does in the image above. Home Header

  • 写回答

2条回答 默认 最新

  • doudi2833 2019-03-22 04:32
    关注

    You are not familiar with PHP so you can use this plugin for the header image. https://wordpress.org/plugins/unique-headers/

    I think its work for you

    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突