excerpt more wordpress
- Accessing Theme Files:
- Navigate to your WordPress dashboard.
Go to "Appearance" and select "Theme Editor."
Locating the Post Template:
In the Theme Editor, find the "content.php" or "single.php" file, depending on your theme.
Locating the Excerpt Code:
Look for the code responsible for displaying the post content. It usually starts with
<?php the_content(); ?>
.Inserting Excerpt Code:
Replace
<?php the_content(); ?>
with<?php the_excerpt(); ?>
. This change will make WordPress display the excerpt instead of the full content.Save Changes:
Click the "Update File" button to save the changes to the theme file.
Adjusting Excerpt Length (Optional):
To control the length of the excerpt, you can add the following code in your theme's functions.php file:
php function custom_excerpt_length($length) { return 20; // Change this number to your desired excerpt length. } add_filter('excerpt_length', 'custom_excerpt_length');
Customizing Read More Link (Optional):
To customize the "Read More" link, add the following code in your theme's functions.php file:
php function custom_read_more_link() { return '<a class="read-more" href="' . get_permalink() . '">Continue Reading</a>'; } add_filter('the_content_more_link', 'custom_read_more_link');
Save Changes (Optional):
Save the changes to the functions.php file.
Viewing the Changes:
Visit your website and check a post to ensure that the excerpt is now displayed instead of the full content.
Adjusting Excerpt Settings (Alternative):
- If your theme supports it, you can go to "Settings" > "Reading" in the WordPress dashboard.
- Under "For each article in a feed, show," select "Summary."
Save changes to apply the excerpt settings globally.
Plugin Alternative (Optional):
- If you prefer a plugin, you can install and activate the "Advanced Excerpt" or similar plugins from the WordPress Plugin Directory.
- Configure the plugin settings to customize the excerpt display.
Remember to make a backup of your theme files before making any changes.