diff --git a/functions.php b/functions.php index 8c1f99b..230bcef 100644 --- a/functions.php +++ b/functions.php @@ -328,8 +328,7 @@ function prefix_ajax_clas_post_content() { //Retrieves post info and content for $object->link = $link; $object->slug = $slug; $object->id = $id; - header('Content-type: application/json'); - echo json_encode($object); + echo wp_json_encode($object); die(); } add_action( 'wp_ajax_clas_tag_posts', 'prefix_ajax_clas_tag_posts' ); @@ -349,8 +348,7 @@ function prefix_ajax_clas_tag_posts() { //Retieves posts of a specific tag, usin $object->$k->title = $title; $object->$k->postID = $id; } - header('Content-type: application/json'); - echo json_encode($object); + echo wp_json_encode($object); die(); } @@ -365,8 +363,9 @@ function prefix_ajax_clas_cat_posts() { //Retieves posts of a specific category $taxName = get_cat_name($val); } else if( $tax == 'tag' ) { $args = "tag_id=".$val."&orderby=post-date&field=ids&numberposts=-1"; - $taxName = get_term( $val, 'tag' )->slug; + $taxName = get_term_by( 'id', $val, 'post_tag' )->slug; } + $ids = get_posts( $args ); if( $val == "0" ){ $ids = get_posts( 'category=19&orderby=post-date&field=ids&numberposts=-1' ); @@ -381,8 +380,7 @@ function prefix_ajax_clas_cat_posts() { //Retieves posts of a specific category $object->$k->taxName = $taxName; } - header('Content-type: application/json'); - echo json_encode($object); + echo wp_json_encode($object); die(); } @@ -404,8 +402,7 @@ function prefix_ajax_clas_search_archive() { //Retieves posts of a specific cate } } - header('Content-type: application/json'); - echo json_encode($object); + echo wp_json_encode($object); die(); } @@ -426,8 +423,7 @@ function prefix_ajax_clas_orderby_posts() { //Retrieves and sorts posts by date $object->$k->title = $title; $object->$k->postID = $id; } - header('Content-type: application/json'); - echo json_encode($object); + echo wp_json_encode($object); die(); } diff --git a/js/custom.js b/js/custom.js index 84123fb..b82ab4b 100644 --- a/js/custom.js +++ b/js/custom.js @@ -264,7 +264,7 @@ jQuery(document).ready(function($) { var taxCap = response[0].taxName.charAt(0).toUpperCase() + response[0].taxName.slice(1); var tax = taxonomy.charAt(0).toUpperCase() + taxonomy.slice(1); currentTaxonomy.set(tax, taxCap); - History.pushState(response, response[0].taxName, url); + History.pushState(response, taxCap, url); var postID = $('ul.news-archive-list li a').first().attr('title'); var data = { action: 'clas_post_content', @@ -417,7 +417,7 @@ jQuery(document).ready(function($) { postdate: '', image: '' }); - } + }//endif }, "json" ); return false;