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


PHP WP_query::the_post方法代码示例

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


在下文中一共展示了WP_query::the_post方法的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: 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

示例4: 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

示例5: 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

示例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: while

            	<div class="container services-wrap">
                      <?php 
    for ($p = 1; $p < 5; $p++) {
        ?>
       
        	<?php 
        if (get_theme_mod('page-column' . $p, false)) {
            ?>
          
        		<?php 
            $queryxxx = new WP_query('page_id=' . get_theme_mod('page-column' . $p, true));
            ?>
				
						<?php 
            while ($queryxxx->have_posts()) {
                $queryxxx->the_post();
                ?>
 
                        <div class="listpages <?php 
                if ($p % 4 == 0) {
                    echo "last_column";
                }
                ?>
">                      
						<a href="<?php 
                the_permalink();
                ?>
"><?php 
                the_post_thumbnail();
                ?>
                       
开发者ID:beatrixmichella,项目名称:fufyflorist,代码行数:30,代码来源:header.php

示例9: array

?>

    <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;
}
$wp_query = null;
$wp_query = new WP_Query();
开发者ID:Alexander-smirnov,项目名称:infomist,代码行数:31,代码来源:navigation-sub.php

示例10: while

	<?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 -->

   <?php 
    wp_reset_postdata();
    ?>
   
   <?php 
开发者ID:amiephipps,项目名称:liachiarotto,代码行数:30,代码来源:template-parent.php

示例11: wp_stripe_options_display_trx

/**
 * Display Transctions on Options Page
 *
 * @since 1.0
 *
 */
function wp_stripe_options_display_trx()
{
    // Paging
    function retrievePage()
    {
        if (!isset($_POST['pagination']) || $_POST['pagination'] == "1") {
            $paged = 1;
        } else {
            $paged = $_POST['pagination'];
        }
        return intval($paged);
    }
    // Query Custom Post Types
    $args = array('post_type' => 'wp-stripe-trx', 'post_status' => 'publish', 'orderby' => 'meta_value_num', 'meta_key' => 'wp-stripe-date', 'order' => 'DESC', 'posts_per_page' => 10, 'paged' => retrievePage());
    // - 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;
        $currency = $custom['wp-stripe-currency'][0];
        $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> ' . $currency . ' (-' . $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>';
    }
    ?>

</table>

<div style="clear:both"></div>

<?php 
    function totalPages($transactions)
    {
        // get total pages
        if ($transactions > 0) {
            $totalpages = floor($transactions / 10) + 1;
        } else {
            return;
        }
        return $totalpages;
    }
    $currentpage = retrievePage();
    $totalpages = totalPages($my_query->found_posts);
    if ($currentpage > 1) {
        echo '<form method="POST" class="pagination">';
        echo '<input type="hidden" name="pagination" value="' . (retrievePage() - 1) . '" />';
        echo '<input type="submit" value="Previous 10" />';
        echo '</form>';
    }
    if ($currentpage < $totalpages) {
        echo '<form method="POST" class="pagination">';
        echo '<input type="hidden" name="pagination" value="' . (retrievePage() + 1) . '" />';
        echo '<input type="submit" value="Next 10" />';
        echo '</form>';
    }
    echo ' <div style="clear:both"></div>';
}
开发者ID:ukrosoft,项目名称:virtuals,代码行数:99,代码来源:stripe-options-transactions.php

示例12: while

      <?php 
}
?>
    </div><!-- /sidebar -->
  </div><!-- /cf -->


  <?php 
if ($projects->have_posts()) {
    ?>
  <div class="inner-section">
    <h2>Projects</h2>
    <ul class="box-list full project-list">
    <?php 
    while ($projects->have_posts()) {
        $projects->the_post();
        ?>
    <?php 
        $challenge_id = get_field('challenge_id');
        $challenge = get_post($challenge_id);
        $challenge_other = trim(get_field('challenge_name'));
        $event_id = get_field('event_id');
        $event = get_post($event_id);
        $event_slug = $event->post_name;
        $event_search_term = get_query_var('project-event');
        if (!$event_search_term || $event_slug == $event_search_term) {
            $found_projects = true;
            ?>
      <li>
        <div class="box-content">
          <h4><a href="<?php 
开发者ID:jamnab,项目名称:hackathon-wordpress-theme,代码行数:31,代码来源:single-event.php

示例13: nirvana_columns_output

            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;
}
// switch
function nirvana_columns_output($columns, $nr_columns)
开发者ID:RishabhTayal,项目名称:GandF,代码行数:31,代码来源:frontpage.php

示例14: while

?>

<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

示例15: while

      <div class="wrapper">
      
         <h4 class="animated fadeIn">My Work</h4>

         <ul class="portfolioItems">

            <?php 
$portfolio = new WP_query(array('post_type' => 'portfolio'));
?>

            <?php 
if ($portfolio->have_posts()) {
    ?>
               <?php 
    while ($portfolio->have_posts()) {
        $portfolio->the_post();
        ?>
                     <li class="animated fadeIn">
                        <div class="portfolioItem">
                           <div class="portfolioImage">
                              <?php 
        the_post_thumbnail('portfolio');
        ?>
                           </div>
                           <div class="portfolioContent">
                              <p><?php 
        the_field('description');
        ?>
</p>
                              <a href="<?php 
        the_field('live_link');
开发者ID:amiephipps,项目名称:amiephippswp,代码行数:31,代码来源:archive-portfolio.php


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