0

In the question "Copy SEO Meta Desc “Custom Field” to Excerpt field?"

The plugin posted as a part of brasofilo's answer works great but, I would like to alter the excerpt for Pages of my WordPress site instead of or in addition to posts. How would I accomplish this?

3
  • 1
    Please explain what you've tried and exactly what doesn't work.
    – s_ha_dum
    May 7 '14 at 17:18
  • 2
    Where did you copy paste that question from? And who are referring to with "you"? Please read the faq to see what this site actually is.
    – kaiser
    May 7 '14 at 17:20
  • I've edited the question to make a little more sense
    – Tom J Nowell
    May 7 '14 at 17:35
1

You have gaps in your knowledge of how data is structured in WordPress. In WordPress all pages/posts etc are 'posts' and have a type.

For example:

  • 'post' posts are blogposts
  • 'attachment' posts are images/videos/audio/uploads
  • 'page' posts are pages

Post types tend to have their own section in the menu on the left of the admin interface. You can add your own too, search for custom post types for how.

In the code you referenced there is a query that grabs all the posts of a certain type, so that it can then loop over them and fix each ones excerpt. It does this by specifying a post_type of 'post' for standard blog posts/news:

'post_type'   => 'post'

This needs to change to the page post type if you're wanting to use it on pages.

1
  • 1
    I'm not really sure how it impacts WordPress, but it may be worth noting that by default, page post-types do not have support for post_excerpt - a call to add_post_type_support( 'page', 'excerpt' ); may be required.
    – bosco
    May 7 '14 at 17:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.