Call the file “all-content.php” and upload it to /wp-content/themes/[YOUR-THEME]/templates.
<?php
/**
* The template for displaying all conetnt
* Template Name: All content
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package otm
*/
get_header();?>
<h1>All Content On Website</h1>
<?php
// Arguments for the query
$args = array(
'post_type' => 'any', // Fetches every post type.
'posts_per_page' => -1, // Retrieves all posts.
);
// The Query
$the_query = new WP_Query($args);
// The Loop
if ($the_query->have_posts()) {
while ($the_query->have_posts()) {
$the_query->the_post();
// Get the edit post link
$edit_post_link = get_edit_post_link();
echo '<div style="margin-top:80px">';
// Display the title with the edit post link
echo '<h2><a href="' . esc_url($edit_post_link) . '">' . get_the_title() . '</a></h2>';
the_content(); // Display the post content
// Yoast SEO Title and Meta Description
$yoast_title = get_post_meta(get_the_ID(), '_yoast_wpseo_title', true);
$yoast_meta_desc = get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true);
// Output Yoast SEO Title and Meta Description inside <pre> tags
if (!empty($yoast_title) || !empty($yoast_meta_desc)) {
echo '<pre style="background: #ececec;border: 1px solid #bfbfbf;padding: 10px;">';
echo 'Yoast SEO Title: ' . esc_html($yoast_title) . "\n";
echo 'Yoast SEO Meta Description: ' . esc_html($yoast_meta_desc);
echo '</pre>';
}
echo '</div>';
}
} else {
// No posts found
echo 'Nothing found.';
}
// Restore original Post Data
wp_reset_postdata();
?>
<?php get_footer();
Note: you might be better off not including the header and footer, as that’ll bring in all the js and css from the site. This’ll cause problems if you’re using accordions or anything like that as ctrl + f might miss stuff in there. Just make sure to add them back in after, or the noindex won’t work