当前位置: 首页>>代码示例>>PHP>>正文


PHP WP_query::have_posts方法代码示例

本文整理汇总了PHP中WP_query::have_posts方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_query::have_posts方法的具体用法?PHP WP_query::have_posts怎么用?PHP WP_query::have_posts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WP_query的用法示例。


在下文中一共展示了WP_query::have_posts方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: subpage_peek

function subpage_peek($atts, $content = null)
{
    global $post;
    // Extract shortcode arguements
    extract(shortcode_atts(array('order' => 'asc', 'orderby' => 'menu_order', 'numpages' => '-1', 'hidethumb' => 'false', 'removelinks' => 'false', 'showfullcontent' => 'false'), $atts));
    //query subpages
    $args = array('post_parent' => $post->ID, 'post_type' => 'page', 'order' => $order, 'orderby' => $orderby, 'posts_per_page' => $numpages);
    $subpages = new WP_query($args);
    $i = 1;
    // create output
    if ($subpages->have_posts()) {
        $output = '<div id="subpage-list">';
        while ($subpages->have_posts()) {
            $subpages->the_post();
            $output .= '<hr /><div class="entry" id="subpage-link-' . $i . '">';
            if ($hidethumb == 'false' && has_post_thumbnail()) {
                // check if the post has a Post Thumbnail assigned to it.
                $output .= '<a href="' . get_permalink() . '" class="alignleft">' . get_the_post_thumbnail($post->ID, 'thumbnail', array('class' => 'wp-post-image')) . '</a>';
            }
            $output .= '<h3>';
            $output .= $removelinks == 'true' ? get_the_title() : '<a href="' . get_permalink() . '">' . get_the_title() . '</a>';
            $output .= '</h3><p>';
            $output .= $showfullcontent == 'true' ? get_the_content() : get_the_excerpt();
            if ($removelinks == 'false') {
                $output .= '<br /><a href="' . get_permalink() . '"><em>Read more &raquo;</em></a>';
            }
            $output .= '</p>
				</div>';
            $i++;
        }
        $output .= '<div style="clear:both;"></div>';
        $output .= '</div>';
    } else {
        $output = '<p>No subpages found.</p>';
    }
    // reset the query
    wp_reset_postdata();
    // return something
    return $output;
}
开发者ID:sezj,项目名称:ufl-template-responsive,代码行数:40,代码来源:shortcode-subpage-peek.php

示例2: image_cpt_shortcode

function image_cpt_shortcode($attr)
{
    if ($attr['page'] <= 10) {
        $per_page['page'] = $attr['page'];
    } else {
        $per_page['page'] = 10;
    }
    $output = '<h2 class="winner-title">Hall of Winners</h2><h3 class="winner-subtitle">Congratulations to all of our winners</h3>';
    $args = array('post_type' => 'image_post_type', 'posts_per_page' => $per_page['page']);
    $loop = new WP_query($args);
    if ($loop->have_posts()) {
        while ($loop->have_posts()) {
            $loop->the_post();
            $output .= '<div class="winner-div"><h3>';
            $output .= get_the_title();
            $output .= '</h3>';
            if (has_post_thumbnail()) {
                // check if the post has a post thumbnail assigned to it.
                $thumb = wp_get_attachment_image_src(get_post_thumbnail_id($loop->ID), 'full');
                $url = $thumb['0'];
                $output .= '<img src="' . $url . '"/>';
            }
            $output .= '</div>';
        }
    } else {
        // if no content, include the "no posts found" template.
        get_template_part('content', 'none');
    }
    return $output;
}
开发者ID:Shane-McCarthy,项目名称:wordpress-custom-theme,代码行数:30,代码来源:functions.php

示例3: mon_espace_pub_show

function mon_espace_pub_show()
{
    $args = array('post_type' => 'slider', 'ignore_sticky_posts' => true);
    $pub = new WP_query($args);
    if ($pub->have_posts()) {
        echo "<div id='pub'>";
        while ($pub->have_posts()) {
            $pub->the_post();
            echo "<div class='la_pub'>";
            the_post_thumbnail('slider');
            echo "</div>";
        }
        echo "</div>";
        wp_reset_postdata();
    }
}
开发者ID:Katario,项目名称:mon_espace_pub,代码行数:16,代码来源:mon_espace_pub.php

示例4: widget

    function widget($args, $instance)
    {
        extract($args);
        $category = isset($instance['category']) ? $instance['category'] : '';
        $postcount = empty($instance['postcount']) ? '5' : $instance['postcount'];
        $offset = empty($instance['offset']) ? '' : $instance['offset'];
        $sticky = isset($instance['sticky']) ? $instance['sticky'] : 0;
        echo $before_widget;
        ?>
        <section id="slider-<?php 
        echo rand(1, 9999);
        ?>
" class="flexslider">
			<ul class="slides"><?php 
        $args = array('posts_per_page' => $postcount, 'cat' => $category, 'offset' => $offset, 'ignore_sticky_posts' => $sticky);
        $slider = new WP_query($args);
        while ($slider->have_posts()) {
            $slider->the_post();
            ?>
				<li>
				<article class="slide-wrap">
					<div class="mh-slider-overlay"></div>
					<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><?php 
            if (has_post_thumbnail()) {
                the_post_thumbnail('content');
            } else {
                echo '<img src="' . get_template_directory_uri() . '/images/noimage_content.png' . '" alt="No Picture" />';
            }
            ?>
					</a>
					<header class="slide-caption">
						<a href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title_attribute();
            ?>
"><h2 class="slide-title"><?php 
            the_title();
            ?>
</h2></a>
					</header>
				</article>
				</li><?php 
        }
        wp_reset_postdata();
        ?>
			</ul>
		</section><?php 
        echo $after_widget;
    }
开发者ID:stealth5,项目名称:luftwaffle,代码行数:57,代码来源:mh-slider.php

示例5: wp_stripe_options_display_projects

/**
 * Projects - Display projects within options page
 */
function wp_stripe_options_display_projects()
{
    // Query Custom Post Types
    $args = array('post_type' => 'wp-stripe-projects', 'post_status' => 'publish', 'orderby' => 'meta_value_num', 'meta_key' => 'wp-stripe-completion', 'order' => 'ASC', 'posts_per_page' => 50);
    // - query -
    $my_query = null;
    $my_query = new WP_query($args);
    while ($my_query->have_posts()) {
        $my_query->the_post();
        $time_format = get_option('time_format');
        // - variables -
        $custom = get_post_custom(get_the_ID());
        $id = $my_query->post->ID;
        $public = $custom["wp-stripe-public"][0];
        $live = $custom["wp-stripe-live"][0];
        $name = $custom["wp-stripe-name"][0];
        $email = $custom["wp-stripe-email"][0];
        $content = get_the_content();
        $date = $custom["wp-stripe-date"][0];
        $cleandate = date('d M', $date);
        $cleantime = date('H:i', $date);
        $amount = $custom["wp-stripe-amount"][0];
        $fee = $custom["wp-stripe-fee"][0] / 100;
        $net = round($amount - $fee, 2);
        echo '<tr>';
        // Dot
        if ($live == 'LIVE') {
            $dotlive = '<div class="dot-stripe-live"></div>';
        } else {
            $dotlive = '<div class="dot-stripe-test"></div>';
        }
        if ($public == 'YES') {
            $dotpublic = '<div class="dot-stripe-public"></div>';
        } else {
            $dotpublic = '<div class="dot-stripe-test"></div>';
        }
        // Person
        $img = get_avatar($email, 32);
        $person = $img . ' <span class="stripe-name">' . $name . '</span>';
        // Received
        $received = '<span class="stripe-netamount"> + ' . $net . '</span> (-' . $fee . ')';
        // Content
        echo '<td>' . $dotlive . $dotpublic . '</td>';
        echo '<td>' . $person . '</td>';
        echo '<td>' . $received . '</td>';
        echo '<td>' . $cleandate . ' - ' . $cleantime . '</td>';
        echo '<td class="stripe-comment">"' . $content . '"</td>';
        echo '</tr>';
    }
}
开发者ID:ukrosoft,项目名称:virtuals,代码行数:53,代码来源:stripe-options-projects.php

示例6: SPD2012_insertPage

/**
 * Create a shortcode to insert content of a page of specified ID
 *
 * @param    array        attributes of shortcode
 * @return     string        $output        Content of page specified, if no page id specified output = null
 */
function SPD2012_insertPage($atts, $content = null)
{
    // Default output if no pageid given
    $output = NULL;
    // extract atts and assign to array
    extract(shortcode_atts(array("page" => ''), $atts));
    // if a page id is specified, then run query
    if (!empty($page)) {
        $pageContent = new WP_query();
        $pageContent->query(array('pagename' => $page));
        while ($pageContent->have_posts()) {
            $pageContent->the_post();
            // assign the content to $output
            $output = get_the_content();
        }
    }
    return $output;
}
开发者ID:AK-Digitale-Gesellschaft,项目名称:Wordpress-Theme,代码行数:24,代码来源:shortcodePageInsert.php

示例7: suffusion_get_headlines

/**
 * Magazine template function to get headlines
 *
 * @return array
 */
function suffusion_get_headlines()
{
    global $post, $wpdb, $suf_mag_headline_limit;
    $headlines = array();
    $solos = array();
    $suf_mag_headline_limit = (int) $suf_mag_headline_limit;
    $quota_full = false;
    // Previously the script was loading all posts into memory using get_posts and checking the meta field. This causes the code to crash if the # posts is high.
    $querystr = "SELECT wposts.*\n\t\tFROM {$wpdb->posts} wposts, {$wpdb->postmeta} wpostmeta\n\t\tWHERE wposts.ID = wpostmeta.post_id\n\t    AND wpostmeta.meta_key = 'suf_magazine_headline'\n\t    AND wpostmeta.meta_value = 'on'\n\t    AND wposts.post_status = 'publish'\n\t    AND wposts.post_type = 'post'\n\t    ORDER BY wposts.post_date DESC\n\t ";
    $head_posts = $wpdb->get_results($querystr, OBJECT);
    foreach ($head_posts as $post) {
        setup_postdata($post);
        $headlines[] = $post;
        $solos[] = $post->ID;
        if (count($headlines) == $suf_mag_headline_limit) {
            $quota_full = true;
            break;
        }
    }
    if ($quota_full) {
        return $headlines;
    }
    $headline_categories = suffusion_get_allowed_categories('suf_mag_headline_categories');
    if (is_array($headline_categories) && count($headline_categories) > 0) {
        $query_cats = array();
        foreach ($headline_categories as $headline_category) {
            $query_cats[] = $headline_category->cat_ID;
        }
        $query_posts = implode(",", array_values($query_cats));
        $cat_query = new WP_query(array('cat' => $query_posts, 'post__not_in' => $solos));
    }
    if (isset($cat_query->posts) && is_array($cat_query->posts)) {
        while ($cat_query->have_posts()) {
            $cat_query->the_post();
            $headlines[] = $post;
            if (count($headlines) == $suf_mag_headline_limit) {
                $quota_full = true;
                break;
            }
        }
    }
    return $headlines;
}
开发者ID:kevinaxu,项目名称:99boulders,代码行数:48,代码来源:magazine-functions.php

示例8: array

 * Template Name: Navigation-sub
 */
get_header();
?>

    <div id="primary" class="content-area interview">
        <main id="main" class="site-main" role="main">
            <?php 
if (function_exists('dimox_breadcrumbs')) {
    dimox_breadcrumbs();
}
?>
            <?php 
$args = array('post_parent' => 103, 'post_type' => 'page', 'paged' => $paged);
$subpages = new WP_query($args);
if ($subpages->have_posts()) {
    $output = '<ul class="menu-event-wrapp">';
    while ($subpages->have_posts()) {
        $subpages->the_post();
        $output .= '<li><div class="thumb"><a href="' . get_permalink() . '">' . get_the_post_thumbnail() . '</a></div></li>';
    }
    $output .= '</ul>';
}
echo $output;
wp_reset_postdata();
?>
            <?php 
$title = get_the_title();
$temp = get_cat_ID($title);
if ($title == 'Інтерв’ю') {
    $temp = 10;
开发者ID:Alexander-smirnov,项目名称:infomist,代码行数:31,代码来源:navigation-sub.php

示例9: while

 * @package master_theme
 */
get_header();
?>

<main> 

	<?php 
// // custom query to display children of this page
?>
   <?php 
$childPosts = new WP_query(array('post_type' => 'page', 'post_parent' => $post->ID, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC'));
?>

    <?php 
if ($childPosts->have_posts()) {
    ?>

 	<div class="container">
      <?php 
    while ($childPosts->have_posts()) {
        $childPosts->the_post();
        ?>
 
          <?php 
        get_template_part('content');
        ?>
      <?php 
    }
    ?>
 	</div><!-- .container -->
开发者ID:amiephipps,项目名称:liachiarotto,代码行数:31,代码来源:template-parent.php

示例10: while

        // if widgets loaded
        if (is_active_sidebar('presentation-page-columns-area')) {
            echo '<div id="front-columns-box"><div id="front-columns" class="ppbox">';
            if ($nirvana_columnstitle) {
                echo "<h2>" . do_shortcode($nirvana_columnstitle) . "</h2>";
            }
            dynamic_sidebar('presentation-page-columns-area');
            echo "</div></div>";
        } else {
            global $nirvana_column_defaults;
            nirvana_columns_output($nirvana_column_defaults, $nirvana_nrcolumns);
        }
        break;
    default:
        if ($nirvana_columnNumber > 0) {
            if ($custom_query2->have_posts()) {
                while ($custom_query2->have_posts()) {
                    $custom_query2->the_post();
                    $img = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'columns');
                    $column['image'] = $img[0];
                    $column['link'] = get_permalink();
                    $column['text'] = get_the_excerpt();
                    $column['title'] = get_the_title();
                    $columns[] = $column;
                }
            }
            nirvana_columns_output($columns, $nirvana_nrcolumns);
        }
        // columnNumber>0
        break;
}
开发者ID:RishabhTayal,项目名称:GandF,代码行数:31,代码来源:frontpage.php

示例11: while

get_header();
?>

<div class="all-box">
  <div class="feature-box-main site-aligner">
    <?php 
for ($f = 1; $f < 5; $f++) {
    ?>
    <?php 
    if (get_theme_mod('page-setting' . $f)) {
        ?>
    <?php 
        $queryvar = new WP_query('page_id=' . get_theme_mod('page-setting' . $f, true));
        ?>
    <?php 
        while ($queryvar->have_posts()) {
            $queryvar->the_post();
            ?>
    <div class="feature-box <?php 
            if ($f % 4 == 0) {
                ?>
last<?php 
            }
            ?>
">
      <?php 
            the_post_thumbnail();
            ?>
      <div class="feature-title">
        <?php 
            the_title();
开发者ID:rictocco,项目名称:cardiosalud,代码行数:31,代码来源:front-page.php

示例12: while

<?php

if (!isset($module_query_args)) {
    return;
}
$the_query = new WP_query($module_query_args);
if ($the_query->have_posts()) {
    ?>
	<div class="module">
		<?php 
    if (isset($module_query_args['fw_heading']['title'])) {
        $module_title = $module_query_args['fw_heading']['title'];
        if (isset($module_query_args['fw_heading']['link'])) {
            //die(var_dump($module_query_args['fw_heading']['link']));
            $module_title = '<a href="' . $module_query_args['fw_heading']['link'] . '">' . $module_title . '<i class="skin-icon skin-icon-plus"></i></a>';
        }
        echo '<div class="module-heading">' . '<h3 class="module-title">' . $module_title . '</h3>' . '</div>';
    }
    ?>
		<?php 
    while ($the_query->have_posts()) {
        $the_query->the_post();
        ?>
			<?php 
        /**
         * Exclude these post in home page listing
         */
        if (isset($post_to_exclude) && !in_array($post->ID, $post_to_exclude)) {
            $post_to_exclude[] = $post->ID;
        }
        ?>
开发者ID:howblect,项目名称:2015_blect_net,代码行数:31,代码来源:listing-grid-excerpt.php

示例13: search_everything_callback

function search_everything_callback()
{
    $is_query = !empty($_GET['s']);
    $result = array();
    if ($is_query) {
        $result = array('own' => array(), 'external' => array());
        $params = array('s' => $_GET['s']);
        $zemanta_response = se_api(array('method' => 'zemanta.suggest', 'return_images' => 0, 'return_rich_objects' => 0, 'return_articles' => 1, 'return_markup' => 0, 'return_rdf_links' => 0, 'return_keywords' => 0, 'careful_pc' => 1, 'interface' => 'wordpress-se', 'format' => 'json', 'emphasis' => $_GET['s'], 'text' => $_GET['text']));
        if (!is_wp_error($zemanta_response) && $zemanta_response['response']['code'] == 200) {
            $result['external'] = json_decode($zemanta_response['body'])->articles;
        }
        $SE = new SearchEverything(true);
        if (!empty($_GET['exact'])) {
            $params['exact'] = true;
        }
        $params["showposts"] = 5;
        $post_query = new WP_query($params);
        while ($post_query->have_posts()) {
            $post_query->the_post();
            $result['own'][] = get_post();
        }
        $post_query->reset_postdata();
    }
    print json_encode($result);
    die;
}
开发者ID:jimmyshen007,项目名称:webproject,代码行数:26,代码来源:search-everything.php

示例14: wp_stripe_delete_tests

function wp_stripe_delete_tests()
{
    if (isset($_POST['wp_stripe_delete_tests']) && $_POST['wp_stripe_delete_tests'] === '1') {
        $test_transactions = new WP_query(array('post_type' => 'wp-stripe-trx', 'post_status' => 'publish', 'posts_per_page' => 500));
        while ($test_transactions->have_posts()) {
            $test_transactions->the_post();
            // Delete Post
            if (get_post_meta(get_the_id(), 'wp-stripe-live', true) === 'TEST') {
                var_dump(the_title());
                wp_delete_post(get_the_id(), true);
            }
        }
        wp_redirect(wp_get_referer());
        exit;
    }
}
开发者ID:ukrosoft,项目名称:virtuals,代码行数:16,代码来源:stripe-options.php

示例15: foreach

<?php

$main_permalink = get_the_permalink();
$userlog = is_user_logged_in();
// Status query
$status = new WP_query(array('post_type' => 'status', 'posts_per_page' => 3));
$i = 0;
while ($status->have_posts()) {
    $status->the_post();
    $comments = get_comments(array('post_id' => get_the_ID(), 'orderby' => 'post_date', 'order' => 'ASC'));
    $comment_count = 0;
    foreach ($comments as $c) {
        $comment_count++;
    }
    $special_class = '';
    $i++;
    if ($i === 1) {
        $special_class = ' first';
    }
    ?>
<div class="status-container<?php 
    echo $special_class;
    ?>
">
    <h4><?php 
    the_title();
    ?>
</h4>
    <div class="status-posts">
    <div class="status-post-count">
        <a href="#" class="status-post-count-show-all"><?php 
开发者ID:JeppeSigaard,项目名称:faaborggym,代码行数:31,代码来源:status-main.php


注:本文中的WP_query::have_posts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。