k_u_api.php
1.1 KB
<?php
require_once( dirname(__FILE__) . '/wp-load.php' );
global $wpdb;
$args = array(
'hide_empty' => 0
);
$weburl = home_url('/');
$ar = [];
$categories = get_categories( $args );
$excpt = [];
if($categories){
foreach($categories as $k=>$v){
if(strtolower($v->name) != 'featured' && strtolower($v->name) != 'featured products'){
$ar[] = get_category_link($v->term_id).'|'.$v->name;
}else{
$excpt[] = $v->term_id;
}
}
}
if($excpt){
$posts = query_posts(array('post_type' => 'post','category__not_in'=> $excpt,'showposts' => 10000));while ( have_posts() ) : the_post();
$post_title = $post->post_title;
$post_title = str_replace('"','',$post_title);
$ar[] = get_permalink($post->ID).'|'.urlencode($post_title);
endwhile; wp_reset_query();
}else{
$posts = query_posts(array('post_type' => 'post','showposts' => 10000));while ( have_posts() ) : the_post();
$post_title = $post->post_title;
$post_title = str_replace('"','',$post_title);
$ar[] = get_permalink($post->ID).'|'.urlencode($post_title);
endwhile; wp_reset_query();
}
print_r(json_encode($ar));exit;