最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

WPML returning posts that are not published

programmeradmin0浏览0评论

I'm working on a website that uses WPL for translation. The website has 2 languages, french (main) and english. The problem I'm facing is that in a list of posts in the, english version, it's showing french posts. In these cases the posts have an english version but not published yet.

This is the query I make and how I loop through it:

                    <ul class="list-item list-inline list-posts clearfix">

                    <?php $args = array(
                        'post_type' => 'post',
                        'posts_per_page' => 12,
                        'post_status' => 'publish',
                        'orderby' => 'date',
                        'order' => 'DESC',
                        'suppress_filters' => false
                    );

                    if ($cat && !$tag):
                        $args['cat'] = $cat['term_id'];
                    endif;

                    if ($sector):
                        $args['cat'] = $sector['term_id'];
                    endif;

                    if ($tag):
                        $args['tag'] = $tag;
                    endif;

                    $query = new WP_Query($args);

                    if ($query->have_posts()):

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

                            $args_cat = array(
                                'parent' => icl_object_id(3, 'category'),
                            );

                            $categories = wp_get_post_categories(get_the_ID(), $args_cat);
                            foreach ($categories as $cat_id) :
                                $category = get_category($cat_id);
                            endforeach;

                            if ($category->term_id == icl_object_id(8, 'category')): ?>
                                <li class="item circulation-alert-post table-cell">
                                <?php get_template_part('content', 'circulation');
                            else: ?>
                                <li class="item">
                                <?php get_template_part('content');
                            endif; ?>
                            </li>
                        <?php endwhile;

                    else:

                        get_template_part('content', 'none');

                    endif;
                    wp_reset_query(); ?>

                </ul>

According to the WPML documentation the parameter 'suppress_filters' => false should do the job, but it's not working.

Would anyone have some clues how I could fix this?

Thanks in advance.

发布评论

评论列表(0)

  1. 暂无评论