小编Jes*_*sse的帖子

Wordpress post__not_in()函数不排除小部件数组中的当前帖子

这是一个带有主题的小部件,它不会从侧边栏中排除列表项.这将从同一地区提取3个房地产列表.它无法排除当前项目.

必须是一些问题,post__not_in()但我没有看到问题.有谁知道这个功能?

function listingsInSameAreaWidget() { ?>

<aside id="other-listings-in-same-area" class="widget left">
<h4><?php _e('Other Listings in Same Area', 'theme_textdomain'); ?></h4>
<ul id="newlistings">
<?php
$author = get_the_author_meta('ID');
$city = get_the_term_list(ID, 'city');
$post_id = get_post($post->ID)->ID;
$args = array(
    'post_type' => 'listings',
    'city' => $city,
    'post__not_in' =>$post->ID,
    'posts_per_page' => 3
);

//query_posts($args);
query_posts( array(
    'post_type' => 'listings',
    'city' => $city,
    'post__not_in' =>$post->ID,
    'posts_per_page' => 3, )

);  
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> 
    <li>
        <?php …
Run Code Online (Sandbox Code Playgroud)

php wordpress widget

1
推荐指数
2
解决办法
1万
查看次数

标签 统计

php ×1

widget ×1

wordpress ×1