Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#9171 closed defect (bug) (invalid)

Shortcodes not outputting correctly

Reported by: ridesign Owned by:
Milestone: Priority: high
Severity: normal Version: 2.7
Component: General Keywords: shortcode, shortcodes
Focuses: Cc:


When using the below shortcodes function, the post id does not output where the shortcode is typed in the post page. The post id is displayed right at the start of the post section.

function shortcode_id() {


} add_shortcode('id', 'shortcode_id');

What outputs on the post page: 10741This is a good post. This is Post ID:

What is typed in the post page: This is a good post. This is Post ID:[id]

Change History (3)

#1 @ridesign
9 years ago

  • Keywords shortcode added

#2 @ridesign
9 years ago

  • Cc ridesign added

#3 @jamescollins
9 years ago

  • Milestone 2.7.2 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Your shortcode_id)() function is supposed to return a string of content, rather than echo'ing out the content directly.

the_ID() echo's the ID.

In your case your shortcode_id() should probably return get_the_ID() instead.

See http://codex.wordpress.org/Shortcode_API for more information.

Note: See TracTickets for help on using tickets.