Php 当值返回产品帖子数组时,查询“meta_key”的帖子标题,然后显示搜索词与链接帖子标题匹配的帖子

Php 当值返回产品帖子数组时,查询“meta_key”的帖子标题,然后显示搜索词与链接帖子标题匹配的帖子,php,arrays,wordpress,loops,meta-key,Php,Arrays,Wordpress,Loops,Meta Key,当关键字返回产品帖子数组时,如何查询meta_关键字的帖子标题,然后仅显示meta关键字自定义关系字段与搜索词匹配的帖子(与产品帖子标题相同) 每个pst中的自定义字段都是ACF关系字段 这是我糟糕的问题 <?php $product = $_GET['s']; // Get the parsed product title to query $related_products = get_field( 'related_products' ); // Get rela

当关键字返回产品帖子数组时,如何查询
meta_关键字的帖子标题
,然后仅显示meta关键字自定义关系字段与搜索词匹配的帖子(与产品帖子标题相同)

每个pst中的自定义字段都是ACF关系字段

这是我糟糕的问题

<?php 

    $product = $_GET['s']; // Get the parsed product title to query
    $related_products = get_field( 'related_products' ); // Get relationship field
           
    //echo $product;

    $knowledge_args = array(
    'post_type'        => 'knowledge_hub',
    'posts_per_page'    => -1,
    'meta_query'    => array(
        'key'       => array ( $related_products['post_name'] ), // This doesn nto work but you can see what i'm trying to do
        'value'     => $product,
        'compare'   => 'LIKE' 
    ),
    );

    print_r($knowledge_args); // This prints to screen the contens fo teh array in the meta_key
    //print_r($related_products);

    $relatedProductArticles = new WP_Query($knowledge_args); ?>
<?php 


if ( have_posts($relatedProductArticles) ) : 
    while ( have_posts($relatedProductArticles) ) : the_post($relatedProductArticles);
        ?>
        
      <article class="col-12 search-item mb-5">
        <div class="row d-flex align-items-center">
          <div class="col-md-7">
            <?php the_post_thumbnail('medium', ['class' => 'w-100']); ?>
          </div>
          <div class="col-md-4">
            <div class="px-4">
              <h2><a class="" href="<?php the_permalink() ?>"><?php the_title() ?></a></h2>
              <?php the_excerpt(); ?>
            </div>
          </div>
        </div>
      </article>
       
<?php
        
    endwhile;
else : ?>

    <h2><?php _e( 'Sorry, no posts matched your criteria.', 'textdomain' );?></h2>
    
  <?php endif;
?>
Array ( [post_type] => knowledge_hub [posts_per_page] => -1 [meta_query] => Array ( [key] => Array ( [0] => WP_Post Object ( [ID] => 20 [post_author] => 1 [post_date] => 2021-01-05 14:27:48 [post_date_gmt] => 2021-01-05 14:27:48 [post_content] => Mid-lateral support The Icon Mid provides support where necessary to help with trunk control and to help decrease fatigue. Sculpted dual-stiffness foam for better fit The sculpted foam fits the shell’s contour without bunching. Soft foam protects the sensitive areas of the spine while firmer foam supports the sides of the trunk. Maximum comfort and protection while moving The Icon Mid features an innovative roll-over cushion and cover to protect the user from contact with the edge of the shell during extension or weight shifting activities. Fail-safe air-foam technology Varilite Icon Mid back supports are fail-safe, meaning even with a puncture you have the benefit of the foam in each cushion. Breathable cover The breathable fabric cover increases air flow between the user and the back support. The cover is machine washable and the cushion can be wiped down easily. [post_title] => Varilite Icon Mid [post_excerpt] => The Varilite Icon Mid back support provides support for the mid-region. The Icon Mid does not interfere with the arm during propelling or other activities as it is situated under the scapulae. [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => varilite-icon-mid [to_ping] => [pinged] => [post_modified] => 2021-04-27 13:20:21 [post_modified_gmt] => 2021-04-27 13:20:21 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost:8888/hia/?post_type=product&p=20 [menu_order] => 60 [post_type] => product [post_mime_type] => [comment_count] => 0 [filter] => raw ) ) [value] => Varilite Icon Mid [compare] => LIKE ) ) Array ( [post_type] => knowledge_hub [posts_per_page] => -1 [meta_query] => Array ( [key] => Array ( [0] => WP_Post Object ( [ID] => 20 [post_author] => 1 [post_date] => 2021-01-05 14:27:48 [post_date_gmt] => 2021-01-05 14:27:48 [post_content] => Mid-lateral support The Icon Mid provides support where necessary to help with trunk control and to help decrease fatigue. Sculpted dual-stiffness foam for better fit The sculpted foam fits the shell’s contour without bunching. Soft foam protects the sensitive areas of the spine while firmer foam supports the sides of the trunk. Maximum comfort and protection while moving The Icon Mid features an innovative roll-over cushion and cover to protect the user from contact with the edge of the shell during extension or weight shifting activities. Fail-safe air-foam technology Varilite Icon Mid back supports are fail-safe, meaning even with a puncture you have the benefit of the foam in each cushion. Breathable cover The breathable fabric cover increases air flow between the user and the back support. The cover is machine washable and the cushion can be wiped down easily. [post_title] => Varilite Icon Mid [post_excerpt] => The Varilite Icon Mid back support provides support for the mid-region. The Icon Mid does not interfere with the arm during propelling or other activities as it is situated under the scapulae. [post_status] => publish [comment_status] => closed [ping_status] => closed [post_password] => [post_name] => varilite-icon-mid [to_ping] => [pinged] => [post_modified] => 2021-04-27 13:20:21 [post_modified_gmt] => 2021-04-27 13:20:21 [post_content_filtered] => [post_parent] => 0 [guid] => http://localhost:8888/hia/?post_type=product&p=20 [menu_order] => 60 [post_type] => product [post_mime_type] => [comment_count] => 0 [filter] => raw ) ) [value] => Varilite Icon Mid [compare] => LIKE ) )