Я испытываю Undefined variable: warning
на моем плагине Wordpress.Неопределенная переменная в wordpress-запросе
Как бы исправить это? Ниже приведен фрагмент запроса в рамках короткого кода и не является полной функцией. В строке, содержащей $ post_thumbnail, я столкнулся с проблемой. Благодарю.
function project_shortcode($atts) {
extract(shortcode_atts(array(
'limit' => '10',
'orderby' => 'date',
), $atts));
$output = '';
$loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => $limit, 'orderby' => $orderby));
// Looping through the posts and building the HTML structure.
if($loop){
$output .= '<ul id="og-grid" class="og-grid">';
while ($loop->have_posts()){
$loop->the_post();
//If has thumbnail
$post_thumbnail_id = get_post_thumbnail_id($post->ID);
$post_thumbnail_url = wp_get_attachment_url($post_thumbnail_id);
UPDATE
Линия $post_thumbnail_id = get_post_thumbnail_id($post->ID);
Есть 2 строки '$ post_thumbnail' в них. Который из? –
извините. Обновленный вопрос – Allreadyhome
, может быть, $ post var отсутствует? Вы также должны получить предупреждения о недостающих $ limit и $ orderby vars .. – Philipp