بدون دسته بندی

How to Add Excerpts to Your Pages in WordPress (Step by


Are you looking for a way to add excerpts to your pages in WordPress?

Excerpts are short extracts from your content that can add a description, summary, or small details about a post or page. By default, excerpts are only available for posts in WordPress.

In this article, we will show you how to easily add excerpts to your pages in WordPress, step-by-step.

Why Add Excerpts to Pages in WordPress?

WordPress comes with posts and pages as two default content types. Posts are displayed in reverse chronological order (latest to oldest) on your blog or homepage.

Pages, on the other hand, are stand-alone content not published in a time-specific order. They are typically used for one-off content like your about us or contact page.

Sometimes, you may need to display excerpts for your pages. For example, this can be handy if you have built a WordPress website using only pages.

Excerpts can provide a better overall user experience by making it easier for visitors to browse through your content and see a summary of your pages.

Having said that, let’s take a look at how to add excerpts to your pages in WordPress and display them on your website. You can use the quick links below to jump between different methods:

How to Add Excerpts to Pages in WordPress

You can enable page excerpts in WordPress by adding custom code to your theme’s functions.php file.

However, the smallest error while typing the code can break your website, and if you switch to a different theme or update it, then you will have to add the code all over again.

That is where WPCode comes in. It is the best WordPress code snippets plugin on the market that makes it safe and easy to add custom code to your website.

First, you must install and activate the WPCode plugin. For detailed instructions, see our step-by-step guide on how to install a WordPress plugin.

Note: WPCode has a free plan that you can use for this tutorial. However, upgrading to the pro version will give you access to a cloud library of code snippets, smart conditional logic, and the CSS snippet option.

Upon activation, visit the Code Snippets » + Add Snippet page from the WordPress dashboard. Here, click the ‘Use Snippet’ button under the ‘Add Your Custom Code (New Snippet)’ option.

Add new snippet

This will take you to the ‘Create Custom Snippet’ page, where you can start by adding a name for the snippet. This name is only for your identification and won’t be displayed on your website’s front end.

Next, select the ‘PHP Snippet’ option from the dropdown menu on the right.

Choose the PHP Snippet option for the page excerpts code

Now, you must add the following custom code into the ‘Code Preview’ box:

add_post_type_support( 'page', 'excerpt' );

Once you do that, scroll down to the ‘Insertion’ section and choose the ‘Auto Insert’ mode.

The custom code will be automatically executed on your website once you activate the snippet.

Choose insertion method

After that, scroll back to the top of the page and toggle the ‘Inactive’ switch to ‘Active’.

Finally, click the ‘Save Snippet’ button to store your settings.

Click the Save Snippet button for the page excerpts code

Now open the page where you want to add an excerpt in the WordPress block editor.

Once you do that, you will notice an ‘Excerpt’ tab in the block panel on the right side of the screen.

Here, you can easily expand the tab and add an excerpt for your WordPress page.

Add page excerpts in the Excerpts tab in the block panel

Once you do that, don’t forget to click the ‘Update’ or ‘Publish’ button to store your changes.

Now, simply repeat the process for all the WordPress pages where you want to add excerpts.

How to Display Page Excerpts in WordPress

Now that you have added the excerpt functionality to your pages, it is time to actually display these excerpts on your WordPress site.

To do this, you will need to add a shortcode to your widget area or page.

First, you must install and activate the Display Posts plugin. For more details, see our beginner’s guide on how to install a WordPress plugin.

This plugin will enable a shortcode that displays 10 recent pages with their title, excerpt, and a continue reading link.

If you didn’t enter a custom excerpt for a page, then the plugin will automatically generate an excerpt for the page with the default length of 55 words.

Method 1: Display Page Excerpts on a WordPress Page

Upon activation, you must create a new page where you want to display a list of your pages and their excerpts.

Once you are there, click the add block ‘+’ button to open the block menu and add the Shortcode block. Next, paste the following shortcode into the block itself:

[display-posts post_type="page" include_excerpt="true" excerpt_more="Continue Reading" excerpt_more_link="true"]

Add the page excerpt shortcode in the block editor

Finally, click the ‘Update’ or ‘Publish’ button to store your settings.

Now, just visit your WordPress site to view the list of page excerpts.

Preview of page excerpts on a page

Method 2: Display Page Excerpts in the WordPress Sidebar

If you want to display page excerpts in the WordPress sidebar, then you must visit the Appearance » Widgets page from the WordPress dashboard.

Note: If you don’t see the ‘Widgets’ menu tab on your dashboard, then it means you are using a block theme. In that case, you can skip to the next method.

Here, click the add block ‘+’ button to expand the block menu on the left. Then, add the Shortcode block to the sidebar area.

Add page excerpts shortcode in a widget area of your choice like the Sidebar

After that, copy and paste the following shortcode into the block:

[display-posts post_type="page" include_excerpt="true" excerpt_more="Continue Reading" excerpt_more_link="true"]

Finally, click the ‘Update’ button to store your settings.

Now, you can visit your WordPress blog to view the page excerpts.

Preview of page excerpts in the WordPress sidebar

Method 3: Display Page Excerpts in the Full Site Editor

If you are using a block theme, then you must visit the Appearance » Editor page from the WordPress admin sidebar.

This will open the full site editor, where you must choose the page where you want to display a list of page excerpts.

Choose a page to edit in the full site editor

Next, click the add block ‘+’ button on the screen to add the Shortcode block.

Then, copy and paste the following shortcode into it:

[display-posts post_type="page" include_excerpt="true" excerpt_more="Continue Reading" excerpt_more_link="true"]

Add page excerpts shortcode in the full site editor

Finally, click the ‘Save’ button to store your settings.

Now, go ahead and visit your website to view the list of page excerpts.

Page excerpts preview in the WordPress block theme

Bonus: Display Post Excerpts in WordPress

Other than pages, it is also a good idea to show post excerpts on your WordPress blog.

By default, WordPress shows your full-length posts on the homepage, archives page, or blog page. This means a lot of scrolling, which can provide a negative user experience to visitors who want to browse through your website quickly.

As your blog grows, the list of your older posts will also be pushed to other pages and get fewer views. That is why you should consider showing post excerpts on your blog or archives page.

An example of post excerpts in a WordPress theme

If you are using a classic theme, then you can add post excerpts by visiting the Appearance » Customize page from the WordPress admin sidebar.

Once the customizer opens up, expand the ‘Blog’ tab in the left column of the screen. This will open some new settings where you can scroll down to the ‘Post Content’ section and click on the ‘Excerpt’ option.

Adding post excerpts to your WordPress website

However, keep in mind that these settings can differ based on the theme that you are using.

If your theme does not support excerpts, then you can use custom code or page builders like SeedProd to add post excerpts to your blog.

Adding blog excerpts to a WordPress theme

For detailed instructions, see our tutorial on how to display post excerpts in WordPress themes.

We hope this article helped you learn how to add excerpts to your pages in WordPress. You may also want to see our guide on how to choose the best website builder or our expert pick of the best live chat software.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.



پایان/ مرجع وب و فناوری

Link to fons nuntium

دکمه بازگشت به بالا