Wordpressのカスタム投稿タイプ用のphpを変更するとサーバーが落ちます

実現したいこと

Wordpressのプラグイン「custom-field-suite」を使用しています。
カスタム投稿タイプ「abc」でsingle-abc.phpを編集しています。
single-abc.phpにおいて、「custom-field-suite」のselect要素のフィールド「abc_industry」「abc_occupation」の値が同じ記事のリストを取得しようとしています。
下記のコードを書き込んだところ、サーバーが落ちてしまいました。恐らく、echo '<a href="' . get_permalink() . '"> の箇所を書き込んだところサーバーが落ちたので、ここが原因かと思いますが、サーバーが落ちた原因と修正方法を教えていただけないでしょうか。
よろしくお願い致します。

発生している問題・エラーメッセージ

サーバーが落ちる

該当のソースコード

php

1<?php2// 現在の投稿のフィールド値を取得3$current_id = get_the_ID(); // 現在の投稿ID4$industry = CFS()->get('abc_industry', $current_id);5$occupation = CFS()->get('abc_occupation', $current_id);6// 制約を生成7$industry_constraints = array_map(function($value) {8 return array(9 'key' => 'abc_industry',10 'value' => $value11 );12}, $industry);13$occupation_constraints = array_map(function($value) {14 return array(15 'key' => 'abc_occupation',16 'value' => $value17 );18}, $occupation);19// それらのフィールド値を持つ他の投稿を取得20$args = array(21'post_type' => 'abc',22'post_status' => 'publish',23'posts_per_page' => -1, // 全ての投稿を取得。必要に応じて変更してください。24'post__not_in' => array($current_id), // 現在の投稿を除外25'meta_query' => array(26 'relation' => 'OR', // industry または occupation が一致する投稿を取得27 array(28 'relation' => 'AND', // industry のすべての条件が一致29 $industry_constraints30 ),31 array(32 'relation' => 'AND', // occupation のすべての条件が一致33 $occupation_constraints34 ),35),36);37$the_query = new WP_Query($args);38// 結果のループ39if ($the_query->have_posts()) {40 while ($the_query->have_posts()) {41 $the_query->the_post();42 echo '<a href="' . get_permalink() . '"><img src="' . CFS()->get('abc_icon') . '" alt="' . get_the_title() . '" width="120" height="120"></a>';43 }44} else {45 echo '該当の記事はありませんでした。';46}47// ループをリセット48wp_reset_postdata();49?>50

コメントを投稿

0 コメント