How to remove article summaries from article archives of Astra themes

Astra The theme is a popular WordPress theme that offers a high degree of customization. Removing article summaries is a common need if you wish to tweak its default settings. Below are the steps on how to remove the article summary in the article archive page of Astra theme.

图片[1]-如何从 Astra 主题的文章归档中移除文章摘要并添加“阅读更多”按钮

Why are article summaries removed?

Article summaries usually display short article introductions on archive pages. These summaries may sometimes affectweb pagedesign or content presentation. If you only want to display the post title and featured image on the archive page, removing the summary makes the page cleaner.

图片[2]-如何从 Astra 主题的文章归档中移除文章摘要并添加“阅读更多”按钮

Step 1:Edit functions.phpremoves

  1. Login to WordPress management back office
    • Access the WordPress dashboard using an administrator account.
  2. Go to the theme file editor
    • leftmenuclicking on exterior condition > Theme File EditorThe
  3. Edit the functions.php file
    • In the theme file editor, locate and click on the functions.php Documentation.
  4. Add code to remove summary
    • exist functions.php Add the following code at the bottom of the file:
add_filter( 'the_excerpt', 'filter_the_excerpt', 10, 2 ); function filter_the_excerpt( ) { return ' '; }

To save the file, click Updated documentsThe

图片[3]-如何从 Astra 主题的文章归档中移除文章摘要并添加“阅读更多”按钮

This code will remove the summary section from the archive page by replacing the article summary with a blank space. After the update, the article archive page will only display the article title and featured image.

图片[4]-如何从 Astra 主题的文章归档中移除文章摘要并添加“阅读更多”按钮

Step 2. Using the "Code Snippets" plugin

The "Code Snippets" plugin makes it easy to add customized code without having to edit it directly. functions.php file. This avoids errors and makes it easier to manage the code.

Steps:

  1. Installation of plug-ins
    • In the WordPress dashboard, go to plug-in (software component) > Installation of plug-insTo do so, search for "Code Snippets" and install and activate the plugin.
图片[5]-如何从 Astra 主题的文章归档中移除文章摘要并添加“阅读更多”按钮
  1. Add Code
    • After activation, go to Snippets > Add NewThe
    • Name your code in the title, for example "Remove Astra Excerpt".
    • Paste the following code in the code box:
add_filter( 'the_excerpt', 'filter_the_excerpt', 10, 2 ); function filter_the_excerpt( $excerpt ) { return ''; // remove article summary }
  1. strike (on the keyboard) Save and activateThe

This completes the operation of using the plugin without the need to modify the theme files directly.

Optional: add a "read more" button

If you want to remove the summary and keep the "Read More" button, you can use the following code:

add_filter( 'the_excerpt', 'filter_the_excerpt', 10, 2 );
function filter_the_excerpt( $excerpt ) {
    $excerpt = ''; // remove the excerpt content

    // Add a "read more" button
    $excerpt . = '<a class="ast-button" href="/en/' . esc_url( get_permalink() ) . '/">' . esc_html__( 'Read More', 'astra' ) . '</a>';

    return $excerpt;
}

With this code, the article summary will be removed and replaced by a "read more" button that the user can click on.buttonsView Full Article.

图片[6]-如何从 Astra 主题的文章归档中移除文章摘要并添加“阅读更多”按钮

final result

After completing the above steps, visit your post archive page and you will see:

  • The summary has been removed.
  • If the use of "Read More" button code, the button will appear under each article.

caveat

  • Backup Sites: Before modifying the theme files, please backup your WordPress website in case of problems.
  • Be careful with the editing.: In the editorial functions.php Be careful with the files, incorrect code may prevent the site from functioning properly.

summarize

With the above steps, you can easily get the best out of the Astra The theme removes the article summary from the article archive page. Just add a simple code snippet to make the page display cleaner and highlight the articlecaptionand featured image. If desired, you can also add a "Read More" button along with the removal of the summary to help users navigate further through the full article. Remember to backup your site and be careful when modifying the theme files. It is recommended that you use a plugin to make changes to ensure that your site works properly.


Contact Us
Can't read the tutorial? Contact us for a free answer! Free help for personal, small business sites!
客服微信
Customer Service
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: [email protected]
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
本文作者:托尼屎大颗
THE END
If you like it, support it.
kudos104 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments