简体   繁体   中英

wordpress custom text in header.php as page of edit field

I been creating a template from scratch in wordpress and now I have a template header with a image in it a text/ subheader text. And below that all some info text. What I want is that I can change that info text like a page or custom field in the backhand of wordpress.

This text as example I want to edit in the backhand : CUSTOM HEADER TEXT

see the code below:

    <!doctype html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="nl" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="nl" > <!--<![endif]-->

  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title><?php echo wp_title(' | ', false, 'right') . get_bloginfo(); ?></title>

    <?php wp_head(); ?>

  </head>

  <body>

 <header>
        <div class="row">
            <div class="large-12 columns">
                        <div class="large-12 columns">

                    <h1><a href="<?php bloginfo('url'); ?>/"><?php bloginfo('name'); ?></a> <span class="description">| <?php bloginfo('description'); ?></span></h1>
                    </div>
                    <p>CUSTOM HEADER TEXT</p>

                    </div>
                </div>
            </div>
 </header>    

Just go to admin => Appearance => Widgets, Drag a text widget in any of your sidebar and put the text "CUSTOM HEADER TEXT" in the text widget and save it.

After that just go to your header file where you want to show this text and put this code snippet : <?php dynamic_sidebar( 'sidebar-1' ); ?> <?php dynamic_sidebar( 'sidebar-1' ); ?> //here 1 is the id of your sidebar

Just check in front end, you will find the text but layout is a little different. To do this pixel perfect, go to your function.php file and search for your sidebar like "sidebar-1" and remove the extra divs from there.

Follow the above steps, you'll get what you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM