WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 4 years ago

#11048 closed enhancement (wontfix)

Add new is_excerpt conditional tag

Reported by: newkind Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: close
Focuses: Cc:
PR Number:

Description

Hi,

I'd like request adding new conditional tag - is_excerpt(). It can be very useful to add some stuff to the posts on frontpage that were splitted using <!--more--> tag.

Change History (6)

#1 @scribu
10 years ago

  • Resolution set to invalid
  • Status changed from new to closed

is_excerpt() wouldn't work because it's on a per-post basis, whereas the rest of the conditional tags are related to the current query.

Please use the Ideas forum.

#2 @westi
10 years ago

  • Milestone 2.9 deleted

#3 @hakre
10 years ago

Next to what scribu is saying (which I must confirm as well), this does not make much sense logically. A themer should be able to find out wich actual template/query is using excerpts or not. So this can be decided by the theme or based on the query itself. There is no general rule.

#4 @jakesee
5 years ago

  • Component changed from General to Plugins
  • Resolution invalid deleted
  • Status changed from closed to reopened

Without referring to the wordpress definition of an excerpt, if a plugin callback function (e.g. shortcode callback) can determine from which context it is being called, then the callback function can do a better customisation.

For example, when a "trimmed version" of a post is called, shortcode callback can skip all translation and return empty string. But when the full post is shown, the callback will normally parse and return the content. Currently, conditional tags such as if(!is_single()) can be used as a workaround.

This should work in places such as the_content() and the_excerpt().

Last edited 5 years ago by jakesee (previous) (diff)

#5 @SergeyBiryukov
5 years ago

  • Component changed from Plugins to Posts, Post Types
  • Keywords close added; new is_excerpt conditional tag removed
  • Milestone set to Awaiting Review

Replying to jakesee:

For example, when a "trimmed version" of a post is called, shortcode callback can skip all translation and return empty string.

Note that wp_trim_excerpt() normally strips all shortcodes.

#6 @wonderboymusic
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from reopened to closed

I think ! is_single() would suffice

Note: See TracTickets for help on using tickets.