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

How to query post only with different excerpt?

programmeradmin1浏览0评论

I have this code, im Using ACF PRO to do a reverse relationship

<?php 

                    /*
                    *  Query posts for a relationship value.
                    *  This method uses the meta_query LIKE to match the string "123" to the database value a:1:{i:0;s:3:"123";} (serialized array)
                    */

                    $related_alerts = get_posts(array(
                        'post_type' => 'alerts',
                        // 'posts_per_page' => 1,
                        'meta_query' => array(
                            array(
                'key' => 'route_affected_by_this_alert', // name of custom field
                'value' => '"' . get_the_ID() . '"', // matches exactly "123", not just 123. This prevents a match for "1234"
                                'compare' => 'LIKE'
                            )

                        )
                    ));

                    ?>

I'm getting the post related to this post. Basically, I have some routes and here I'm getting the alerts related to these routes. The problem is that the client creates the alerts many times with different titles affecting the same alerts and I'm getting the same alert many times in a route with the same content. They are different post (alerts) but with the same content. The question is how can I just query the post without the same title or excerpt or content? What I want to know if you can help me to avoid querying content with the same content or excerpt, thank you very much.

发布评论

评论列表(0)

  1. 暂无评论