Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mariusbratu

    (@mariusbratu)

    In such case, is there a safe way to have the title of the post outside of loop? Can you please make a suggestion here?

    Thread Starter mariusbratu

    (@mariusbratu)

    Thank you all for your answers!

    So i think its safe to have the_title() outside of loop. As it will always be a single post. I was concerned that there are situations where the page.php template will list more than one post, and that i wasnt aware of such case.

    My current code looks like this:

    <?php get_header(); ?>
    <div class="container breadcrumb">
        <div class="inner-container clearfix">
    	    <span class="dot"></span>
            <h1 class="h2"><?php the_title(); ?></h1>
        </div>
    </div>
    
    <div class="container">
    	<div class="inner-container clearfix">
    		<?php while (have_posts()) : the_post(); ?>
            <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
                <section class="entry-content">
                    <?php the_content(); ?>
                </section> <!-- end article section -->
            </article> <!-- end article -->
            <?php endwhile; ?>
    	</div>
    </div>
    <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)