So I set my home page to "Your latest posts", and included this bit of code to get the info from a pre-defined page so that I can edit my home page, and get access to a "recent posts" grid with pagination at the same time. In addition, I can edit this post via the Gutenberg Block editor with this method.
I'd like to eliminate the possibility of a "duplicate content" flag on my content, so should I no-index the source page?
<picture class="featured-image block pos-rel">
<div class="t-con flex row pos-abs">
<h1 class="post-title f-center" title="<?php echo get_the_title( $ID=2 ); ?>"><?php echo get_the_title( $ID=2 ); ?></h1> <!--Edit these values to adjust page being shown.-->
</div>
<?php the_post_thumbnail( 'full', array(
'class' => 'featured'
)); ?>
</picture>
<?php get_search_form(); ?>
<section class="main bg-darkpurple">
<?php
$id=2;
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
Also, I'm aware that the the_title_attribute()
should be used in place of echo get_the_title($ID=2)
however, when I use that, even with $ID declared, It outputs the attribute of the latest post instead.
Thanks for the insight!
So I set my home page to "Your latest posts", and included this bit of code to get the info from a pre-defined page so that I can edit my home page, and get access to a "recent posts" grid with pagination at the same time. In addition, I can edit this post via the Gutenberg Block editor with this method.
I'd like to eliminate the possibility of a "duplicate content" flag on my content, so should I no-index the source page?
<picture class="featured-image block pos-rel">
<div class="t-con flex row pos-abs">
<h1 class="post-title f-center" title="<?php echo get_the_title( $ID=2 ); ?>"><?php echo get_the_title( $ID=2 ); ?></h1> <!--Edit these values to adjust page being shown.-->
</div>
<?php the_post_thumbnail( 'full', array(
'class' => 'featured'
)); ?>
</picture>
<?php get_search_form(); ?>
<section class="main bg-darkpurple">
<?php
$id=2;
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
Also, I'm aware that the the_title_attribute()
should be used in place of echo get_the_title($ID=2)
however, when I use that, even with $ID declared, It outputs the attribute of the latest post instead.
Thanks for the insight!
Share Improve this question asked Jan 17, 2020 at 19:31 DevonDevon 356 bronze badges1 Answer
Reset to default 0Rather than just no-indexing the Page, 301 redirect it. This can be done either by server config (.htaccess, NGINX rules, etc.) or using a plugin. That way no one can actually get to the Page all on its own - it only exists on the front page.