Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#13096 closed enhancement (duplicate)

Use custom taxonomies with get_adjacent_post()

Reported by: zerzix's profile zerzix Owned by: frumph's profile Frumph
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Taxonomy Keywords: needs-patch
Focuses: Cc:

Description

I would like to use Hierarchical taxonomies in the Get_adjacent_post() function in the pace of the hard coded category. I feel that this is a needed enhancement with the enhanced custom taxonomy functions.

Attachments (2)

get_adjacent_post.patch (1.8 KB) - added by zerzix 14 years ago.
diff for get_adjacent_post, not tested
13096.patch (3.3 KB) - added by SergeyBiryukov 13 years ago.

Download all attachments as: .zip

Change History (16)

#1 @PeteMall
14 years ago

  • Component changed from General to Taxonomy
  • Keywords needs-patch added; taxomixy get_adjacent_post() removed
  • Milestone changed from Unassigned to Future Release
  • Owner set to filosofo
  • Summary changed from use custome taxomonies with get_adjacent_post() to use custom taxomonies with get_adjacent_post()

#2 @PeteMall
14 years ago

  • Summary changed from use custom taxomonies with get_adjacent_post() to Use custom taxonomies with get_adjacent_post()

@zerzix
14 years ago

diff for get_adjacent_post, not tested

#3 @Frumph
14 years ago

  • Keywords has-patch added; needs-patch removed

#4 @filosofo
14 years ago

  • Owner changed from filosofo to Frumph
  • Status changed from new to assigned

#5 @Frumph
14 years ago

  • Keywords needs-testing added

#6 @nacin
14 years ago

  • Keywords needs-patch added; has-patch needs-testing removed

We need to prepare those strings then. We might want to also double-check get_taxonomies to make sure the requested taxonomy is registered.

#7 @kevinB
14 years ago

  • Cc kevinB added

#9 @SergeyBiryukov
13 years ago

Turned Frumph's solution into a patch.

#10 @SergeyBiryukov
13 years ago

  • Keywords has-patch added; needs-patch removed

#11 @Frumph
13 years ago

@Sergey Please double check the apply_filters part where I added the _${taxonomy} part if that would work or not, that's an area i'm not familiar with

#12 @SergeyBiryukov
13 years ago

  • Keywords needs-patch added; has-patch removed

It seems that the function is not working as is, since there is no post taxonomy.

#13 @Frumph
13 years ago

http://wp.pastebin.com/j61WThB6

Yep, okay here's a different route,

Excerpt:

function get_adjacent_post($in_same_category = false, $previous = true, $excluded_categories = '', $taxonomy = '') {
	global $post, $wpdb;
	
	if ( empty( $post ) || ( !empty($taxonomy) && !taxonomy_exists( $taxonomy ) ) )
		return null;

If it's an empty post, or it's not an empty taxonomy && the taxonomy doesn't exist, return null

that should be a good sanity check on the taxonomy

#14 @scribu
13 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from assigned to closed

Marking as duplicate of #17807 (newer patch).

Note: See TracTickets for help on using tickets.