Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 需要显示来自搜索的否定结果(Wordpress插件)_Php_Wordpress - Fatal编程技术网

Php 需要显示来自搜索的否定结果(Wordpress插件)

Php 需要显示来自搜索的否定结果(Wordpress插件),php,wordpress,Php,Wordpress,我一直在努力显示用户不喜欢使用此wordpress插件的帖子列表: 我已经重新创建了一个搜索,我可以将它转换成一个自定义的短代码,但我不知道如何将其反转以显示不受欢迎的列表 此外,我想显示标题,并有标题链接到页面-有人可以帮助吗?这就是我所拥有的: $favorites = get_user_favorites(); if ( $favorites ) : $favorites_query = new WP_Query( array( 'post_type'

我一直在努力显示用户不喜欢使用此wordpress插件的帖子列表:

我已经重新创建了一个搜索,我可以将它转换成一个自定义的短代码,但我不知道如何将其反转以显示不受欢迎的列表

此外,我想显示标题,并有标题链接到页面-有人可以帮助吗?这就是我所拥有的:

$favorites = get_user_favorites();

    if ( $favorites ) :

    $favorites_query = new WP_Query( array(
        'post_type' => 'product',
        'posts_per_page' => -1,
        'post__in' => $favorites
    ));

    if ( $favorites_query->have_posts() ) :

        while ( $favorites_query->have_posts() ) : $favorites_query->the_post();

            echo '<p>' . get_the_title( $favorite ) . '</p>';

        endwhile;

    endif;

    wp_reset_postdata();

endif;
$favorites=get_user_favorites();
如果($favorites):
$favorites\u query=新的WP\u查询(数组(
“post_类型”=>“产品”,
“每页帖子数”=>-1,
“在中发布”=>$favorites
));
如果($favorites\u query->have\u posts()):
而($favorites\u query->have\u posts()):$favorites\u query->the\u post();
回音“”。获取标题($favorite)。'

",; 结束时; endif; wp_reset_postdata(); endif;
我想知道你的意思是:

 $favorites_query = new WP_Query( array(
        'post_type' => 'product',
        'posts_per_page' => -1,
        'post__not_in' => $favorites
    ));
我们在中使用
post\u not\u而不是在
中使用
post\u

从:

post\u不在
(数组)中-使用post id。指定不检索的帖子。如果 这与
中的
post\u在同一查询中使用,将被忽略


但是请注意,返回的帖子数量可能会很大,每页
posts\u
as-1.

非常感谢您,我已经花了9个小时试图解决这个问题。不客气,很高兴听到您正在寻找它@乔马索尔