本文整理汇总了PHP中WP_Query::has_posts方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Query::has_posts方法的具体用法?PHP WP_Query::has_posts怎么用?PHP WP_Query::has_posts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Query
的用法示例。
在下文中一共展示了WP_Query::has_posts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: person_save_action
/**
* Actions on person save.
*
* When a person is saved, we get the positions that they are assigned to,
* and add their email to each position list, if it is not already in the
* specified list.
*
* @since 1.0.0
* @param int $post_id The post ID.
* @param post $post The post object.
* @param bool $updated Whether this is an existing post being updated or not.
*/
public function person_save_action($post_id, $post, $updated)
{
$slug = 'oaldr_person';
if ($slug !== $post->post_type) {
return;
}
$fname = get_field('first_name', $post_id);
$lname = get_field('last_name', $post_id);
$person_email = get_field('person_email', $post_id);
$parent_email = get_field('parent_email', $post_id);
$title = get_the_title();
if ($person_email) {
$options = array('post_type' => 'oaldr_position', 'posts_per_page' => 50, 'meta_query' => array(array('key' => 'person', 'value' => $post_id, 'compare' => 'LIKE')));
$query = new WP_Query($options);
if ($query->has_posts()) {
$slack_invite = $this->slack->invite_member($post_id, $fname, $lname, $person_email);
$addresses = [];
foreach ($query->posts as $post) {
$position_email = get_field('position_email', $post->id);
// $this->mailgun->add_list_member( $position_email, $person_email, $fname.' '.$lname );
$addresses[] = ['address' => $person_email, 'name' => $fname . ' ' . $lname];
}
$addresses = json_encode($addresses);
$this->mailgun->add_array_list_members($position_email, $addresses);
}
}
}