I am trying to place the content of the about page inside a div on the header , the template part is located on folder template-parts/content-about.php
on the header the code is:
<div id="slideOut">
<div class="slideout-content">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', 'about' );
endwhile; // End of the loop.
?>
<?php include 'content-about.php'; ?>
</div><!-- .slideout-content -->
</div>
And the content-about.php looks like this:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<?php
the_content();
wp_link_pages(
array(
'before' => '<div class="page-links">' . esc_html__( 'Pages:', 'about' ),
'after' => '</div>',
)
);
?>
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->
The issue is that is showing on the div the same content as the current page for example if I'm located on home page it shows only the content of the home page inside the div when it should always show the content of the about page. why is not working? Thanks
content-about.php
telling it to get the content from that page. If you look in your file, you are usingthe_content()
. Since that is in the loop, it will get the content from whatever page you are on. You can useget_the_content()
and pass the about pageid
to that function. Just because the file is namedcontent-about
doesn't mean that it gets content from that pate. – disinfor