I've written a loop which works on my local machine but not on my dev server. My dev server is running PHP 7.4.13 and my MAMPRO is running 7.4.12.

The dev server code displays nothing and with no errors and the local version displays as expected.

7.4.12 is not installed my server so I cannot test to see if it is a version issue.

I tried printing the variables at different stages, but nothing happened inside the if(in_array part.

Is the PHP version difference likely to be the cause or is it likely to be something else?

                // Query products where product title matches a tag in the current article

                $current_article_tags = wp_get_object_terms(get_the_ID(), 'knowledge_hub_tag', array('fields' => 'names'));

                //echo '<pre>'; print_r($current_article_tags); echo '</pre>';

                $related_products = new WP_Query(array(
                  'posts_per_page' => -1,
                  'post_type'=> 'product',
                  /*'post_title' => array(
                          //'taxonomy' => $current_article_tags,
                          'post_title' => 'varilite icon mid',
                          'operator'=> 'IN' //Or 'AND' or 'NOT IN'

                //echo '<pre>'; print_r($related_products); echo '</pre>';

                $products = $related_products->posts;

                //echo '<pre>'; print_r($products); echo '</pre>';

                //if ($related_products->have_posts()){

                    foreach($products as $product) {

                        if(in_array($product->post_title, $current_article_tags, true)) {                                
                            echo '<p><a href="'.get_permalink( $product ).'">'.get_the_title($product).'</a></p>';


  • Is your content exactly the same on your dev server? What is an example of a post title and $current_article_tags? Commented Jul 2, 2021 at 10:51
  • Example post title is 'wheelchair tall' and tag also would be 'wheelchair tall'. The content isn't exactly the same, but i have tested a 'Knolwedge Hub' post by adding a tag that matches that of an existing 'product' post title and nothing displays.
    – Amesey
    Commented Jul 2, 2021 at 11:00
  • 1
    Are the tag and the post title capitalised the same way? Commented Jul 2, 2021 at 11:13
  • No, but when I try to make the tags capitalise they revert back, could this be the issue?
    – Amesey
    Commented Jul 2, 2021 at 11:19
  • I've just noticed the tags on my local are capitalised!! So why does my dev server version revert them back?
    – Amesey
    Commented Jul 2, 2021 at 11:21

1 Answer 1


I've fixed it! It was the capitalisation. I edited the tags via tags menu section and now the products are displaying :) thank you very much @Jacob Peattie

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.