ดังนั้นสิ่งนี้อาจดูเหมือนเป็นสิ่งที่ผู้ชายน่ารัก แต่ตามฉันมาที่นี่
ฉันพยายามเพิ่มตรรกะผ่านการpre_get_posts
กระทำ นี่เป็นวัตถุ WP_Query ทั้งหมดที่มอบให้ฉัน (ดูตอนท้าย)
สิ่งที่ฉันได้พิจารณาการใช้:
is_single()
- กว้างเกินไปis_singular()
- เร็วเกินไปที่จะใช้สิ่งนี้เนื่องจากget_queried_object()
ยังไม่ได้ตั้งค่า$query->single
อสังหาริมทรัพย์ - กว้างเกินไปอีกครั้ง$query->get('post_type')
- ไม่ได้ตั้งค่าเนื่องจากใช้name
คุณสมบัติ
เป็นname
ตัวบ่งชี้เดียวที่นี่จริง ๆ
WP_Query Object
(
[query] => Array
(
[page] =>
[name] => abcs-of-mental-health
)
[query_vars] => Array
(
[page] =>
[name] => abcs-of-mental-health
[error] =>
[m] => 0
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[comments_popup] =>
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[fields] =>
[menu_order] =>
[category__in] => Array
(
)
[category__not_in] => Array
(
)
[category__and] => Array
(
)
[post__in] => Array
(
)
[post__not_in] => Array
(
)
[tag__in] => Array
(
)
[tag__not_in] => Array
(
)
[tag__and] => Array
(
)
[tag_slug__in] => Array
(
)
[tag_slug__and] => Array
(
)
[post_parent__in] => Array
(
)
[post_parent__not_in] => Array
(
)
)
[tax_query] =>
[meta_query] =>
[queried_object] =>
[queried_object_id] => 0
[post_count] => 0
[current_post] => -1
[in_the_loop] =>
[comment_count] => 0
[current_comment] => -1
[found_posts] => 0
[max_num_pages] => 0
[max_num_comment_pages] => 0
[is_single] => 1
[is_preview] =>
[is_page] =>
[is_archive] =>
[is_date] =>
[is_year] =>
[is_month] =>
[is_day] =>
[is_time] =>
[is_author] =>
[is_category] =>
[is_tag] =>
[is_tax] =>
[is_search] =>
[is_feed] =>
[is_comment_feed] =>
[is_trackback] =>
[is_home] =>
[is_404] =>
[is_comments_popup] =>
[is_paged] =>
[is_admin] =>
[is_attachment] =>
[is_singular] => 1
[is_robots] =>
[is_posts_page] =>
[is_post_type_archive] =>
[query_vars_hash] => f473ebf7f725c2627dc5fd9a1429f626
[query_vars_changed] =>
[thumbnails_cached] =>
)
pre_get_posts
(ก่อนเรียกใช้แบบสอบถาม)