• Ziegremic1988

    (@ziegremic1988)


    Hej, prosiłbym o pomoc bo jestem nowy w WordPressie i boję się, że coś źle robie. Poniżej znajdziecie kod od strony głównej tj. index. php. Moje pytanie jest takie, czy mogę do tej strony głównej dodać element html np paragraf <p>próbka</p> bez wpisywania kodu php? Poniżej ilustracja o co mi chodzi. W tym przypadku chciałym ten element dać do headera. A jeśli chciałbym go dać do środkowej części strony głównej to czy w tym przypadku go właściwie umieściłem

    get_header(); ?>

    <div id=”primary” class=”content-area”>
    <main id=”main” class=”site-main” role=”main”>

    <?php if ( have_posts() ) : ?>

    <?php if ( is_home() && ! is_front_page() ) : ?>
    <header>
    <h1 class=”page-title screen-reader-text”><?php single_post_title(); ?></h1>
    <p>próbka</p>
    </header>
    <?php endif; ?>

    <?php
    // Start the loop.
    while ( have_posts() ) : the_post();

    /*
    * Include the Post-Format-specific template for the content.
    * If you want to override this in a child theme, then include a file
    * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    */
    get_template_part( 'template-parts/content’, get_post_format() );

    // End the loop.
    endwhile;

    // Previous/next page navigation.
    the_posts_pagination( array(
    'prev_text’ => __( 'Previous page’, 'twentysixteen’ ),
    'next_text’ => __( 'Next page’, 'twentysixteen’ ),
    'before_page_number’ => '<span class=”meta-nav screen-reader-text”>’ . __( 'Page’, 'twentysixteen’ ) . ’ </span>’,
    ) );

    // If no content, include the „No posts found” template.
    else :
    get_template_part( 'template-parts/content’, 'none’ );

    endif;
    ?>
    <p>próbka</p>

    </main><!– .site-main –>
    </div><!– .content-area –>

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

Zobacz 1 odpowiedź (z 1 wszystkich)
  • Nikodemsky

    (@nikodemsky)

    Za nagłówek odpowiada header.php, nie index.php to raz.

    Dwa – jeśli chcesz, aby element pojawiał się tylko na stronie głównej, to musiałbyś dodać zależność is_front_page() wraz z odpowiednim kodem.

    W rzadkich przypadkach skórki, które mają przygotowaną stronę główną mają również przypięte elementy nagłówka, przy których możesz dodać elementy.

Zobacz 1 odpowiedź (z 1 wszystkich)

Temat ‘Dodanie paragrafu/elemntu html do index.php’ jest zamknięty na nowe odpowiedzi.