Automatic Indexing without plugin
If you prefer to create the table without using a plugin, you can create a custom template file for your WordPress theme that displays all your posts and pages in a table format. Here’s how:
- Create a new file in your theme directory and name it something like page-index.php.
- Add the following code to the top of your file to define the template name and enable it to be selected in the WordPress page editor:
php
<?php
/*
Template Name: Index Page
*/
?>
- Add the following code to the rest of your file to display the table:
<?php get_header(); ?>
<div id=”primary” class=”content-area”>
<main id=”main” class=”site-main” role=”main”>
<table>
<thead>
<tr>
<th>Title</th>
<th>Excerpt</th>
</tr>
</thead>
<tbody>
<?php
$args = array(
‘post_type’ => array(‘post’, ‘page’),
‘posts_per_page’ => -1,
‘order’ => ‘ASC’,
‘orderby’ => ‘title’
);
$posts = get_posts($args);
foreach ($posts as $post) :
setup_postdata($post);
?>
<tr>
<td><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></td>
<td><?php the_excerpt(); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</main>
</div>
<?php get_footer(); ?>
This code creates a table that includes the title and excerpt of each post and page, ordered alphabetically by the title.
- Save the file and upload it to your theme directory.
- In the WordPress page editor, create a new page and select the “Index Page” template from the “Page Attributes” section.
- Publish the page to display the table.
That’s it! Your WordPress site now has a page with a table that indexes all your posts and pages alphabetically and includes a short excerpt, without using a plugin.
To create a single page that indexes all your posts and pages in one place, you can use a combination of the previous methods. Here’s how:
- Create a new page in the WordPress page editor and give it a title like “Site Index”.
- In the “Page Attributes” section, select the “Index Page” template that you created in the previous answer.
- In the content editor, add the following shortcode:
python
[table id=0 /]
This shortcode will display the table of posts and pages that you created in the page-index.php template.
- Save and publish the page.
Now, when you visit the “Site Index” page on your WordPress site, you will see a table that indexes all your posts and pages in one place, ordered alphabetically by title and including a short excerpt for each post and page.
Now without using the theme editor, simple code on index wordpress page
You can create a simple WordPress page that displays a table of your posts and pages without using the theme editor. Here’s how:
- Create a new page in the WordPress page editor and give it a title like “Site Index”.
- In the content editor, add the following shortcode:
csharp
[posts_table columns=”date,title,excerpt” links=”title” order_by=”title” sort_order=”asc”]
This shortcode will display a table of all your posts and pages, ordered alphabetically by title and including a short excerpt for each post and page.
- Save and publish the page.
That’s it! When you visit the “Site Index” page on your WordPress site, you will see a table that indexes all your posts and pages in one place, ordered alphabetically by title and including a short excerpt for each post and page.
Shop Corner
Php on Amazon
Python on Amazon
Csharp on Amazon
Pascal on Amazon
Thank you for reading and sharing!
Source OpenAI’s ChatGPT Language Model and DALLE – Images Picsart
Invest in your future & learn
Learn affiliate marketing & build your own website.
Heads up! Make sure you sign up using my referral link to get access to my personal coaching and all features.
👉 Sign Up