WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

#13096 closed enhancement (duplicate)

Use custom taxonomies with get_adjacent_post()

Reported by: zerzix Owned by: 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 7 years ago.
diff for get_adjacent_post, not tested
13096.patch (3.3 KB) - added by SergeyBiryukov 7 years ago.

Download all attachments as: .zip

Change History (16)

#1 @PeteMall
7 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
7 years ago

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

@zerzix
7 years ago

diff for get_adjacent_post, not tested

#3 @Frumph
7 years ago

  • Keywords has-patch added; needs-patch removed

#4 @filosofo
7 years ago

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

#5 @Frumph
7 years ago

  • Keywords needs-testing added

#6 @nacin
7 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
7 years ago

  • Cc kevinB added

#9 @SergeyBiryukov
7 years ago

Turned Frumph's solution into a patch.

#10 @SergeyBiryukov
7 years ago

  • Keywords has-patch added; needs-patch removed

#11 @Frumph
7 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
7 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
7 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
6 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.