I've been working on creating a link in my header, should say "see enter next category name here"
I've been using this code, found here (I would comment again to ask directly on that question, but I'm not allowed)
function get_adjacent_category($category_slug,$taxonomy,$type){
global $wpdb;
if($type=="next"){
$operater=" > ";
$orderby=" ORDER BY tt.`term_id` ASC ";
}else{
$operater=" < ";
$orderby=" ORDER BY tt.`term_id` DESC ";
}
$query="SELECT *,(SELECT `term_id` FROM wp_terms WHERE `slug`='".$category_slug."') AS given_term_id,
(SELECT parent FROM wp_term_taxonomy WHERE `term_id`=given_term_id) AS parent_id
FROM `wp_terms` t
INNER JOIN `wp_term_taxonomy` tt ON (`t`.`term_id` = `tt`.`term_id`)
HAVING tt.taxonomy='".$taxonomy."' AND tt.`parent`=parent_id AND tt.`term_id` $operater given_term_id $orderby LIMIT 1";
return $wpdb->get_row($query);
}
$next_category = get_adjacent_category($slug,$taxonomy,"next");
$previous_category = get_adjacent_category($slug,$taxonomy,"previous");
and while I'm not getting an errors, it's not pulling the next category up for me. Just a blank space. Here's the code I'm using to call the function:
<div style="float:right;">See<?php get_adjacent_category($slug,$taxonomy,"next"); ?></div>
Am I calling it incorrectly? If it helps, I'm working with Thesis theme, and here's the website I'm working with. I'm trying to place it on an archive page, mirroring to the "back to blog" link at the top.
Any insight would be greatly appreciated!!
echo
ing anything, and if you tried you wouldn't get what you expect becauseget_row()
returns an Object by default. These are both basic PHP problems.var_dump()
your data from the function and see if it looks right. – s_ha_dum Mar 7 '14 at 15:51