[wp-trac] [WordPress Trac] #32833: previous_post_link/next_post_link disappear when excluding by post_format
WordPress Trac
noreply at wordpress.org
Tue Jun 30 03:50:53 UTC 2015
#32833: previous_post_link/next_post_link disappear when excluding by post_format
--------------------------+-----------------------------
Reporter: markshiz | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.2.2
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
The following code gives me back a term_id from get_term_by, but causes
the next/previous links to disappear:
{{{
<?php print_r(get_taxonomies()); ?>
<?php print_r(get_term_by('slug', 'post-format-aside',
'post_format')->term_id); ?>
<?php previous_post_link('‹ %link', '%title', false,
array(get_term_by('slug', 'post-format-aside', 'post_format')->term_id ));
?>
<?php next_post_link('%link ›', '%title', false,
array(get_term_by('slug', 'post-format-aside', 'post_format')->term_id ));
?>
}}}
The object returned by get_term_by is:
{{{
STDCLASS OBJECT ( [TERM_ID] => 10 [NAME] => ASIDE [SLUG] => POST-FORMAT-
ASIDE [TERM_GROUP] => 0 [TERM_TAXONOMY_ID] => 10 [TAXONOMY] => POST_FORMAT
[DESCRIPTION] => [PARENT] => 0 [COUNT] => 0 [FILTER] => RAW )
UPDATE 2
}}}
When I enable the Wordpress query debugging, I see the following query
being triggered, which is the empty set.
{{{
[mysql> SELECT P.ID FROM WP_POSTS AS P INNER JOIN WP_TERM_RELATIONSHIPS AS
TR ON P.ID = TR.OBJECT_ID INNER JOIN WP_TERM_TAXONOMY TT ON
TR.TERM_TAXONOMY_ID = TT.TERM_TAXONOMY_ID WHERE P.POST_DATE < '2015-06-01
20:10:00' AND P.POST_TYPE = 'PROJECT' AND TT.TAXONOMY = 'CATEGORY' AND
P.ID NOT IN ( SELECT TR.OBJECT_ID FROM WP_TERM_RELATIONSHIPS TR LEFT JOIN
WP_TERM_TAXONOMY TT ON (TR.TERM_TAXONOMY_ID = TT.TERM_TAXONOMY_ID) WHERE
TT.TERM_ID IN (10) ) AND ( P.POST_STATUS = 'PUBLISH' OR P.POST_STATUS =
'PRIVATE' ) ORDER BY P.POST_DATE DESC ;]
Empty set (0.01 sec)
}}}
What's strange about the above is that the query appears to be attempting
to find the previous post based on the category taxonomy, which I have
explicitly asked the function not to do through the query parameters. This
seems like a bug in Wordpress to me.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32833>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list