Ejemplo n.º 1
0
/**
 * wwh_get_category 组合查询数据
 * 
 * @access public
 * @return void
 */
function wwh_get_category()
{
    global $post;
    $cats = wwh_get_cats();
    // $cats = $cats ? $cats : 1;
    /* $cats = $cats.'1,'; */
    $args = array('category__in' => explode(',', $cats), 'ignore_sticky_posts' => 1);
    if (is_single()) {
        $args['posts_per_page'] = 3;
        $args['post__not_in'] = explode(',', $post->ID);
    } else {
        $args['posts_per_page'] = 4;
    }
    return $args;
}
Ejemplo n.º 2
0
<?php

get_header();
/* 文章页  */
$cats = wwh_get_cats();
if (!$cats) {
    $cats = 1;
}
$cat_name = get_cat_name($cats);
$cat_links = get_category_link($cats);
echo $posts_to_show;
/* 当前文章id */
$post_id = get_the_ID();
/* primary 菜单对象 */
$menu = wp_get_nav_menu_object('primary');
/* $wpdb->postmeta 父级菜单 post_id */
$parent = $wpdb->get_results("\n        select meta_value as parent from {$wpdb->postmeta} where post_id = \n        (select post_id from {$wpdb->postmeta},{$wpdb->term_relationships} term_rel where meta_value = {$post_id} and meta_key = '_menu_item_object_id'\n            and term_rel.object_id = post_id and term_rel.term_taxonomy_id = {$menu->term_id}\n        )\n        and meta_key = '_menu_item_menu_item_parent'");
/* 当前文章所有同级文章信息 $wpdb->postmet  */
$renchilds = $wpdb->get_results("\n        select post_id from {$wpdb->postmeta} meta,{$wpdb->posts} post where meta_value = {$parent[0]->parent} and meta_key = '_menu_item_menu_item_parent'\n        and meta.post_id = post.ID\n        order by post.menu_order\n            ");
/* 获得文章 ID */
foreach ($renchilds as $renchild) {
    $post_child = $wpdb->get_results("\n            select meta_value as ID from {$wpdb->postmeta} where post_id = {$renchild->post_id}\n            and meta_key = '_menu_item_object_id'\n        ");
    $post_childs[] = $post_child[0];
}
?>
<div class="nav-back">
    <div class="container container-margin nav-lists">
        <div>
            <a href="/">首页</a> > 
            <?php 
/* 输出分类名或父级 名称 */