B
B
brb22020-04-16 21:32:02
WordPress
brb2, 2020-04-16 21:32:02

How to add another header?

How to add title, code below

<div class="container">
        <?php
          $header_1 = get_post_meta( $post->ID, 'header-1', true );
          $header_2 = get_post_meta( $post->ID, 'header-2', true );
        ?>
        <?php if($header_1): ?><h1 class="header__title"><?= $header_1 ?></h1><?php endif; ?>
        <?php if($header_2): ?><p class="header__subtitle"><span class="title-text"><?= $header_2 ?></span></p><?php endif; ?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rasschitai, 2020-04-16
@rasschitai

smart question) if we continue the logical series, then 1,2,3 ...

W
WP Panda, 2020-04-16
@wppanda5

$n = 1;
while ( $n <= 3 ) {
  $header = get_post_meta( $post->ID, 'header-' . $n, true );
  if ( ! empty( $header ) ) {
    echo $header;
  }
  $n ++;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question