WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#7749 closed enhancement (fixed)

LOOP and return Request: Enable echo=0 and style=none for wp_get_archives

Reported by: nublooo Owned by: ryan
Milestone: 2.7 Priority: normal
Severity: normal Version: 2.6.1
Component: General Keywords: archives, wp_get_archives, echo archives has-patch, commit
Focuses: Cc:

Description

An option of formatting the output of wp_get_archives in a similar way as wp_list_categories, for use in PHP before echoing it.

Suggestion: add the query-string-style parameter "echo" as in wp_list_categories and wp_list_pages to the archives function.

Attachments (2)

7749.1.diff (2.5 KB) - added by ShaneF 7 years ago.
allow "echo" option. Default echo turned on
7749.diff (3.2 KB) - added by DD32 6 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 @ShaneF7 years ago

  • Keywords has-patch commit added

Your wish is our command. :)

@ShaneF7 years ago

allow "echo" option. Default echo turned on

comment:2 @ShaneF7 years ago

  • Owner changed from anonymous to ryan

comment:3 @ryan7 years ago

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

(In [8902]) Add echo option to wp_get_archives(). Props ShaneF. fixes #7749

comment:4 @michelwp6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Summary changed from Request: Enable echo=0 and style=none for wp_get_archives to LOOP and return Request: Enable echo=0 and style=none for wp_get_archives

JUST A MISTAKE : because return are in LOOP, the behaviour is not correct and not like than echo...

The better code must be for each loop and each end of loop in if/endif series :

if ($echo)	
						echo get_archives_link($url, $text, $format, $before, $after);
					else
						$output .= get_archives_link($url, $text, $format, $before, $after);			
				}
			}
			if (!$echo) return $output;

comment:5 @michelwp6 years ago

Just a short add : normally one function - one output ... it is probably possible to set only one output (echoing) and the end-end of the function...

@DD326 years ago

comment:6 @DD326 years ago

attachment 7749.diff added.

  • Moves echo/return outside of loops

comment:7 @ryan6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [9333]) Move echo/return outside of loops. Props DD32. fixes #7749

Note: See TracTickets for help on using tickets.