本文整理汇总了PHP中WP_Query::next_post方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Query::next_post方法的具体用法?PHP WP_Query::next_post怎么用?PHP WP_Query::next_post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Query
的用法示例。
在下文中一共展示了WP_Query::next_post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ciGetAllStaff
function ciGetAllStaff($maxNumEmployees = 100, $maxCharLength = -1)
{
$query = new WP_Query('showposts=' . $maxNumEmployees . '&post_type=' . CI_STAFF_TYPE);
$employeeArray = array();
while ($query->have_posts()) {
$query->next_post();
$attachment = wp_get_attachment_image_src(get_post_thumbnail_id($query->post->ID), CI_STAFF_IMG);
$maybeExcerpt = has_excerpt($query->post->ID) ? $query->post->post_excerpt : $query->post->post_content;
$employeeArray[] = array('id' => $query->post->ID, 'content' => ciFilterToMaxCharLength($maybeExcerpt, $maxCharLength), 'fullContent' => $query->post->post_content, 'title' => $query->post->post_title, 'imgURL' => $attachment ? $attachment[0] : '', 'imgWidth' => $attachment ? $attachment[1] : -1, 'imgHeight' => $attachment ? $attachment[2] : -1, 'url' => get_permalink($query->post->ID), 'socialURLs' => function_exists('ciGetStaffSocialURLs') ? ciGetStaffSocialURLs($query->post->ID) : array());
}
wp_reset_postdata();
return $employeeArray;
}
示例2: ciGetPostsOfType
function ciGetPostsOfType($postType = 'post', $maxCharLength = -1, $featuredImageSize = array(1000, 1000), $maxNumPosts = 100, $orderBy = 'date', $order = ORDER_ASC)
{
$query = new WP_Query("showposts={$maxNumPosts}&post_type={$postType}&orderby={$orderBy}&order={$order}");
$postsArray = array();
while ($query->have_posts()) {
$query->next_post();
$attachment = wp_get_attachment_image_src(get_post_thumbnail_id($query->post->ID), $featuredImageSize);
$maybeExcerpt = has_excerpt($query->post->ID) ? get_post_field('post_excerpt', $query->post->ID) : $query->post->post_content;
$postsArray[] = array('id' => $query->post->ID, 'content' => apply_filters('the_content', ciFilterToMaxCharLength($maybeExcerpt, $maxCharLength)), 'fullContent' => apply_filters('the_content', $query->post->post_content), 'title' => $query->post->post_title, 'imgURL' => $attachment ? $attachment[0] : '', 'imgWidth' => $attachment ? $attachment[1] : -1, 'imgHeight' => $attachment ? $attachment[2] : -1, 'url' => get_permalink($query->post->ID));
}
wp_reset_postdata();
return $postsArray;
}
示例3: _post
private static function _post($term_id, $taxonomy = null)
{
// Allow first argument to be term object instead
if (is_object($term_id)) {
$taxonomy = $term_id->taxonomy;
$term_id = $term_id->term_id;
}
// Get or create the post whose name is _meta_{$taxonomy}_{$term_id}.
//
// This naming format is used to take advantage of the index on post_name
// so we can quickly pull the meta-containing post object from a known term object.
//
// Conversely, if we need to do a search on meta (which is non-optimal,) we can
// easily extract the correct taxonomy and term from the post_name
$post_name = sanitize_key('_meta_' . $taxonomy . '_' . $term_id);
$post_query = new WP_Query(array('post_type' => self::post_type, 'post_status' => self::post_type, 'posts_per_page' => 1, 'name' => $post_name));
if ($post_query->have_posts()) {
$post = $post_query->next_post();
} else {
if (current_user_can('edit_posts')) {
$post_id = wp_insert_post(array('post_name' => $post_name, 'post_type' => self::post_type, 'post_status' => self::post_type));
$post = get_post($post_id);
}
}
return isset($post) ? $post : null;
}
示例4: get_active_liveblogs
/**
* @param $post_type
* @return array
*/
public function get_active_liveblogs($post_type)
{
$liveblogs = array();
$query = new WP_Query(array('meta_key' => '_liveblog', 'meta_value' => '1', 'post_type' => $post_type, 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'DESC'));
// Get all active live blogs
while ($query->have_posts()) {
$query->next_post();
$liveblogs[strval($query->post->ID)] = esc_attr($query->post->post_title);
}
return $liveblogs;
}
示例5: popmake_preload_popups
function popmake_preload_popups()
{
global $popmake_loaded_popups, $popmake_loaded_popup_ids;
$query = new WP_Query(array('post_type' => 'popup', 'posts_per_page' => -1));
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->next_post();
if (popmake_popup_is_loadable($query->post->ID)) {
do_action('popmake_preload_popup', $query->post->ID);
$popmake_loaded_popups->posts[] = $query->post;
$popmake_loaded_popups->post_count++;
}
}
}
}
示例6: podlove_get_episodes_deprecations
function podlove_get_episodes_deprecations()
{
$deprecations = [];
$shortcodes_data = podlove_get_deprecated_shortcodes();
$shortcode_matcher = array_keys($shortcodes_data);
$query = new \WP_Query(['post_type' => 'podcast']);
while ($query->have_posts()) {
$post = $query->next_post();
foreach ($shortcode_matcher as $shortcode) {
if (preg_match("/" . $shortcode . "/", $post->post_content, $matches)) {
$deprecations[] = ['context' => ['type' => 'post', 'id' => $post->ID], 'deprecated' => ['type' => 'shortcode', 'content' => $matches[0]], 'instead' => $shortcodes_data[$shortcode]];
}
}
// hint: template tags don't need to be checked in episodes because they only work in templates
}
return $deprecations;
}
示例7: array
/**
* Get information about current website(s) as pillar data
* suitable for specified minion.
* TODO: which minion?!
* @param string $minion_id id of minion to return pillar data for.
* @return pillar data structure
*/
function get_pillar($minion_id)
{
//debug_halt("here!");
$qargs = array('post_type' => 'wpss_site', 'post_status' => 'any');
$query = new WP_Query($qargs);
$apachesites = array();
$wpsssites = array();
while ($query->have_posts()) {
$post = $query->next_post();
$id = strval($post->ID);
// TODO: servername?
$servername = '127.0.0.1';
// TODO real port vs external?
$port = ':8080';
// TODO: type option?
$type = 'wordpress';
$locations = array();
if (array_key_exists($servername, $apachesites)) {
$locations = $apachesites[$servername]['locations'];
}
$urlpath = '/' . $post->post_name;
// TODO: duplicates/clashes??
$directory = '/srv/selfservice/' . $id;
if ('publish' === $post->post_status) {
$available = true;
$defaultMessage = 'Available';
} else {
$available = false;
$defaultMessage = 'Site not available (' . $post->post_status . ')';
}
$author = get_userdata($post->post_author);
if (false === $author) {
if ($available) {
$defaultMessage = 'Site not available (could not find author ' . $post->post_author . ')';
}
$available = false;
}
$locations[$urlpath] = array('DocumentRoot' => $directory, 'available' => $available, 'defaultMessage' => $defaultMessage, 'id' => $id);
$apachesites[$servername] = array('locations' => $locations);
$url = 'http://' . $servername . $port . $urlpath;
$wpsssites[$directory] = array('id' => $id, 'type' => $type, 'admin_password_hash' => $author->user_pass, 'title' => $post->post_title, 'description' => $post->post_content, 'url' => $url, 'status' => $post->post_status, 'template' => wpss_get_selected_template_for_website($id));
}
$pillar = array('apache' => array('sites' => $apachesites), 'selfservice' => array('sites' => $wpsssites));
return $pillar;
}
示例8: display_setting
/**
* Display this setting
* @since 1.0
*/
public function display_setting()
{
$posts = new WP_Query($this->args);
?>
<select name="<?php
echo $this->get_input_name();
?>
" id="<?php
echo $this->get_input_name();
?>
">
<?php
if ($this->blank_option === true) {
?>
<option></option>
<?php
}
?>
<?php
while ($posts->have_posts()) {
$posts->next_post();
?>
<option value="<?php
echo absint($posts->post->ID);
?>
" <?php
selected($this->value, $posts->post->ID);
?>
><?php
echo esc_attr($posts->post->post_title);
?>
</option>
<?php
}
?>
</select>
<?php
wp_reset_postdata();
$this->display_description();
}
示例9: ciGetAllSlides
/**
* @param $category string Name of the category to filter. If empty, we'll return slides from all categories.
* @param $maxNumSlides int Maximum number of slides to return
* @param $size string One of two constants: SIZE_LG or SIZE_MD (use MD if the image will be in a container div)
* @return array All the slide data you need. Keys are 'content', 'title', 'imgURL', 'imgWidth', and 'imgHeight'
*/
function ciGetAllSlides($category, $maxNumSlides, $size)
{
if ($size == CI_SIZE_INPAGE) {
$size = CI_SIZE_MD;
}
$query = null;
if ($category) {
$query = new WP_Query(array('category_name' => $category, 'post_type' => CI_SLIDE_TYPE, 'showposts' => $maxNumSlides));
} else {
$query = new WP_Query('showposts=' . $maxNumSlides . '&post_type=' . CI_SLIDE_TYPE);
}
$slidesArray = array();
while ($query->have_posts()) {
$query->next_post();
$attachment = wp_get_attachment_image_src(get_post_thumbnail_id($query->post->ID), $size);
if ($attachment) {
$slidesArray[] = array('id' => $query->post->ID, 'content' => apply_filters('the_content', $query->post->post_content), 'title' => apply_filters('the_title', $query->post->post_title), 'imgURL' => $attachment[0], 'imgWidth' => $attachment[1], 'imgHeight' => $attachment[2], 'contentPosition' => ciGetNormalizedMeta('caption_position', 'center', $query->post->ID), 'bg' => ciGetNormalizedMeta('caption_bg', '', $query->post->ID), 'link' => ciGetNormalizedMeta('link', '', $query->post->ID), 'darken' => ciGetNormalizedMeta('darken_slide', true, $query->post->ID));
}
}
wp_reset_postdata();
return $slidesArray;
}
示例10: next_gallery
public function next_gallery()
{
return parent::next_post();
}
示例11: prepare
/**
* Function prepare returns the required html and enqueues
* the scripts and stylesheets necessary for displaying the slideshow
*
* Passing this function no parameter or passing it a negative one will
* result in a random pick of slideshow
*
* @since 2.1.0
* @param int $postId
* @return String $output
*/
static function prepare($postId = null)
{
$post = null;
// Get post by its ID, if the ID is not a negative value
if (is_numeric($postId) && $postId >= 0) {
$post = get_post($postId);
}
// Get slideshow by slug when it's a non-empty string
if ($post === null && is_string($postId) && !is_numeric($postId) && !empty($postId)) {
$query = new WP_Query(array('post_type' => SlideshowPluginPostType::$postType, 'name' => $postId, 'orderby' => 'post_date', 'order' => 'DESC', 'suppress_filters' => true));
if ($query->have_posts()) {
$post = $query->next_post();
}
}
// When no slideshow is found, get one at random
if ($post === null) {
$post = get_posts(array('numberposts' => 1, 'offset' => 0, 'orderby' => 'rand', 'post_type' => SlideshowPluginPostType::$postType, 'suppress_filters' => true));
if (is_array($post)) {
$post = $post[0];
}
}
// Exit on error
if ($post === null) {
return '<!-- Wordpress Slideshow - No slideshows available -->';
}
// Log slideshow's issues to be able to track them on the page.
$log = array();
// Get views
$views = SlideshowPluginSlideshowSettingsHandler::getViews($post->ID);
if (!is_array($views) || count($views) <= 0) {
$log[] = 'No views were found';
}
// Get settings
$settings = SlideshowPluginSlideshowSettingsHandler::getSettings($post->ID);
$styleSettings = SlideshowPluginSlideshowSettingsHandler::getStyleSettings($post->ID);
// The slideshow's session ID, allows JavaScript and CSS to distinguish between multiple slideshows
$sessionID = self::$sessionCounter++;
// Try to get a custom stylesheet
if (isset($styleSettings['style'])) {
// Try to get the custom style's version
$customStyle = get_option($styleSettings['style'], false);
$customStyleVersion = false;
if ($customStyle) {
$customStyleVersion = get_option($styleSettings['style'] . '_version', false);
}
// Style name and version
if ($customStyle && $customStyleVersion) {
$styleName = $styleSettings['style'];
$styleVersion = $customStyleVersion;
} else {
$styleName = str_replace('.css', '', $styleSettings['style']);
$styleVersion = SlideshowPluginMain::$version;
}
} else {
$styleName = 'style-light';
$styleVersion = SlideshowPluginMain::$version;
}
// Register function stylesheet
wp_enqueue_style('slideshow-jquery-image-gallery-stylesheet_functional', SlideshowPluginMain::getPluginUrl() . '/style/' . __CLASS__ . '/functional.css', array(), SlideshowPluginMain::$version);
// Enqueue stylesheet
wp_enqueue_style('slideshow-jquery-image-gallery-ajax-stylesheet_' . $styleName, admin_url('admin-ajax.php?action=slideshow_jquery_image_gallery_load_stylesheet&style=' . $styleName), array(), $styleVersion);
// Include output file to store output in $output.
$output = '';
ob_start();
include SlideshowPluginMain::getPluginPath() . '/views/' . __CLASS__ . '/slideshow.php';
$output .= ob_get_clean();
// Enqueue slideshow script
wp_enqueue_script('slideshow-jquery-image-gallery-script', SlideshowPluginMain::getPluginUrl() . '/js/' . __CLASS__ . '/slideshow.min.js', array('jquery'), SlideshowPluginMain::$version);
// Set dimensionWidth and dimensionHeight if dimensions should be preserved
if (isset($settings['preserveSlideshowDimensions']) && $settings['preserveSlideshowDimensions'] == 'true') {
$aspectRatio = explode(':', $settings['aspectRatio']);
// Width
if (isset($aspectRatio[0]) && is_numeric($aspectRatio[0])) {
$settings['dimensionWidth'] = $aspectRatio[0];
} else {
$settings['dimensionWidth'] = 1;
}
// Height
if (isset($aspectRatio[1]) && is_numeric($aspectRatio[1])) {
$settings['dimensionHeight'] = $aspectRatio[1];
} else {
$settings['dimensionHeight'] = 1;
}
}
// Include slideshow settings by localizing them
wp_localize_script('slideshow-jquery-image-gallery-script', 'SlideshowPluginSettings_' . $sessionID, $settings);
// Return output
return $output;
}
示例12: widget
/**
* @see WP_Widget::widget()
*/
public function widget($args, $instance)
{
$data = new stdClass();
if (isset($instance['title'])) {
$data->title = $instance['title'];
} else {
$data->title = '';
}
if (isset($instance['contest_ID']) && is_numeric($instance['contest_ID'])) {
$contest_ID = intval($instance['contest_ID']);
} else {
$contest_ID = $this->latest_entry_ID;
}
$latest_entries_query = new WP_Query();
$latest_entries_query_options = array('post_type' => 'pronamic_photo_entry', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => 1, 'meta_query' => array(array('key' => '_thumbnail_id')));
// Get the latest entry of a specific contest
if ($contest_ID != $this->latest_entry_ID) {
$latest_entries_query = new WP_Query(array_merge_recursive($latest_entries_query_options, array('meta_query' => array(array('key' => '_pronamic_photo_contest_id', 'value' => $contest_ID)))));
}
// Get the latest entry of any contest when the contest ID is set to retrieve the latest entry, or no entries have been found for a specific contest
if ($contest_ID == $this->latest_entry_ID || !$latest_entries_query->have_posts()) {
$latest_entries_query = new WP_Query($latest_entries_query_options);
}
$data->image = $data->message = '';
if ($latest_entries_query->have_posts()) {
$latest_entry = $latest_entries_query->next_post();
$contest_id = get_post_meta($latest_entry->ID, '_pronamic_photo_contest_id', true);
$width = $height = 0;
if (isset($instance['width']) && is_numeric($instance['width'])) {
$width = $instance['width'];
}
if (isset($instance['height']) && is_numeric($instance['height'])) {
$height = $instance['height'];
}
$data->image .= '<a href="' . get_permalink($contest_id) . '">';
if ($width > 0 && $height > 0) {
$data->image .= get_the_post_thumbnail($latest_entry->ID, array($instance['width'], $instance['height']));
} else {
$data->image .= get_the_post_thumbnail($latest_entry->ID);
}
$data->image .= '</a>';
} else {
$data->message .= __('No entries have been posted yet.', 'pronamic_photo_contest');
}
if (isset($instance['content'])) {
$data->content = $instance['content'];
} else {
$data->content = '';
}
$data->beforeWidget = $data->afterWidget = $data->beforeTitle = $data->afterTitle = '';
if (isset($args['before_widget'])) {
$data->beforeWidget = $args['before_widget'];
}
if (isset($args['after_widget'])) {
$data->afterWidget = $args['after_widget'];
}
if (isset($args['before_title'])) {
$data->beforeTitle = $args['before_title'];
}
if (isset($args['after_title'])) {
$data->afterTitle = $args['after_title'];
}
include $this->plugin->path . 'admin' . DIRECTORY_SEPARATOR . 'latest_entries_widget.php';
}
开发者ID:joffcrabtree,项目名称:wp-pronamic-photo-contest,代码行数:67,代码来源:Pronamic_WP_PhotoContestPlugin_LatestEntriesWidget.php
示例13: form
/**
* Print the form to configure this widget in the admin panel
* @since 1.0
*/
public function form($instance)
{
$id = null;
if (isset($instance['id'])) {
$id = $instance['id'];
}
?>
<p>
<label for="<?php
echo $this->get_field_id('title');
?>
"> <?php
_e('Title');
?>
</label>
<input class="widefat" id="<?php
echo $this->get_field_id('title');
?>
" name="<?php
echo $this->get_field_name('title');
?>
" type="text"<?php
if (isset($instance['title'])) {
?>
value="<?php
echo esc_attr($instance['title']);
?>
"<?php
}
?>
>
</p>
<p>
<label for="<?php
echo $this->get_field_id('id');
?>
"> <?php
_e('Menu Item');
?>
</label>
<select id="<?php
echo $this->get_field_id('id');
?>
" name="<?php
echo $this->get_field_name('id');
?>
">
<?php
$items = new WP_Query(array('posts_per_page' => -1, 'post_type' => 'fdm-menu-item'));
while ($items->have_posts()) {
$items->next_post();
?>
<option value="<?php
echo $items->post->ID;
?>
"<?php
if ($items->post->ID == $id) {
?>
selected<?php
}
?>
>
<?php
echo esc_attr($items->post->post_title);
?>
</option>
<?php
}
// Reset the loop so we don't interfere with normal template functions
wp_reset_postdata();
?>
</select>
</p>
<?php
}
示例14: array
/**
* Get posts
*
* @param array $field
*
* @return array
*/
static function get_options($field)
{
$options = array();
$query = new WP_Query($field['query_args']);
if ($query->have_posts()) {
while ($query->have_posts()) {
$post = $query->next_post();
$title = apply_filters('rwmb_post_field_title', $post->post_title, $post);
$title = apply_filters("rwmb_{$field['id']}_field_title", $title, $post);
$options[$post->ID] = $post_title;
}
}
return $options;
}
示例15: getCharts
/**
* Fetches charts from database.
*
* @since 1.0.0
*
* @access public
*/
public function getCharts()
{
$query_args = array('post_type' => Visualizer_Plugin::CPT_VISUALIZER, 'posts_per_page' => 9, 'paged' => filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'default' => 1))));
$filter = filter_input(INPUT_GET, 'filter');
if ($filter && in_array($filter, Visualizer_Plugin::getChartTypes())) {
$query_args['meta_query'] = array(array('key' => Visualizer_Plugin::CF_CHART_TYPE, 'value' => $filter, 'compare' => '='));
}
$query = new WP_Query($query_args);
$charts = array();
while ($query->have_posts()) {
$chart = $query->next_post();
$chart_data = $this->_getChartArray($chart);
$chart_data['id'] = $chart->ID;
$charts[] = $chart_data;
}
$this->_sendResponse(array('success' => true, 'data' => $charts, 'total' => $query->max_num_pages));
}