當前位置: 首頁>>代碼示例>>PHP>>正文


PHP the_post函數代碼示例

本文整理匯總了PHP中the_post函數的典型用法代碼示例。如果您正苦於以下問題:PHP the_post函數的具體用法?PHP the_post怎麽用?PHP the_post使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了the_post函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: post_excerpts_here

function post_excerpts_here()
{
    //posts with date, author, time, content excerpts, and title..
    if (have_posts()) {
        while (have_posts()) {
            echo '<div class="excerpt-div">';
            the_post();
            echo '<h2 class="post-title"><a href="';
            the_permalink();
            echo '" title="';
            the_title();
            echo '">';
            the_title();
            echo '</a></h2>';
            echo '<h4 class="post-info">';
            echo 'Created on ';
            the_date();
            echo ' at ';
            the_time();
            echo ' by ';
            the_author_meta(first_name);
            echo '.</h4>';
            echo '<p class="post-excerpt">';
            the_excerpt();
            echo '</p>';
            echo '</div>';
        }
        // end while
    }
    // end if
}
開發者ID:jbrown25,項目名稱:Apicat-WP-theme,代碼行數:31,代碼來源:functions.php

示例2: us_web_standards_infinite_scroll_render

/**
 * Custom render function for Infinite Scroll.
 */
function us_web_standards_infinite_scroll_render()
{
    while (have_posts()) {
        the_post();
        get_template_part('template-parts/content', get_post_format());
    }
}
開發者ID:saracope,項目名稱:us-web-standards-wordpress-theme,代碼行數:10,代碼來源:jetpack.php

示例3: doublecheeseburger_infinite_scroll_render

/**
 * Custom render function for Infinite Scroll.
 */
function doublecheeseburger_infinite_scroll_render()
{
    while (have_posts()) {
        the_post();
        get_template_part('template-parts/content', get_post_format());
    }
}
開發者ID:ptums,項目名稱:DoubleBaconCheeseBurger,代碼行數:10,代碼來源:jetpack.php

示例4: featured_index

    function featured_index()
    {
        $output = '';
        $args = array('tag' => 'featured', 'posts_per_page' => 3);
        query_posts($args);
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                $the_img = $this->get_img_src(get_the_ID());
                if ($the_img == 'zero') {
                }
                $output .= '<div class=" mdl-cell mdl-cell--4-col mdl-card mdl-shadow--2dp">';
                $output .= ' <div class="mdl-card__title mdl-card--expand" style="background-image: url( \' ' . $the_img . '  \' )">
							  </div>
							  <div class="mdl-card__supporting-text">
								' . get_the_title() . '
							  </div>
							  <div class="mdl-card__actions mdl-card--border">
								<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
								  View Updates
								</a>
							  </div>';
                $output .= '</div>';
            }
        } else {
            $output = 'gagal';
        }
        wp_reset_query();
        return $output;
    }
開發者ID:madebyaris,項目名稱:arisdes-wp-blog,代碼行數:30,代碼來源:mdl_custom.php

示例5: component_s_infinite_scroll_render

/**
 * Custom render function for Infinite Scroll.
 */
function component_s_infinite_scroll_render()
{
    while (have_posts()) {
        the_post();
        get_template_part('components/content', get_post_format());
    }
}
開發者ID:sixhours,項目名稱:theme-pattern-library,代碼行數:10,代碼來源:jetpack.php

示例6: show_category

function show_category($cid = 1)
{
    $args = array('showposts' => 4, 'cat' => $cid, 'orderby' => 'post_date', 'order' => 'desc');
    query_posts($args);
    global $the_post;
    $category = '';
    while (have_posts()) {
        the_post();
        $cat = get_the_category(get_the_ID());
        $link = get_permalink(get_the_ID());
        $src = get_the_post_thumbnail(get_the_ID(), 'index_thumb');
        $c_name = $cat[0]->name;
        $title = get_the_title();
        echo $category .= <<<EOF
        <div class="box">
          <a href="{$link}">
          <div class="boximg">{$src}</div>
          <div class="category">{$c_name}</div>
          <p>{$title}</p>
          </a>
        </div>
EOF;
    }
    wp_reset_query();
    return $category;
}
開發者ID:bloemen,項目名稱:success,代碼行數:26,代碼來源:top-category.php

示例7: ajax_navigation_callback

function ajax_navigation_callback()
{
    global $wp_query, $page_no, $loop, $query;
    // this is how you get access to the database
    $loop = empty($_POST['loop']) ? 'loop' : $_POST['loop'];
    $posts_per_page = get_option('posts_per_page');
    //merge the query array and paged
    $query = $_POST;
    unset($query['action']);
    unset($query['loop']);
    ob_start();
    # Load the posts
    if ($loop) {
        query_posts($query);
        while (have_posts()) {
            the_post();
            get_template_part($loop);
        }
    }
    $buffer = ob_get_contents();
    ob_end_clean();
    echo $buffer;
    exit;
    // this is required to return a proper result
}
開發者ID:MrBoy31,項目名稱:helpful-intranet,代碼行數:25,代碼來源:ajax-pagination-front.php

示例8: friend_list_func

    public static function friend_list_func($atts, $content = "")
    {
        $atts = shortcode_atts(array('per_page' => '100'), $atts, 'friend_list');
        $return = "";
        query_posts(array('post_type' => 'friend', 'showposts' => $atts['per_page'], 'meta_query' => array('relation' => 'AND', array('key' => 'avatar150', 'value' => 'https://static0.fitbit.com/images/profile/defaultProfile_100_male.gif', 'compare' => 'NOT LIKE'), array('key' => 'avatar150', 'value' => 'https://static0.fitbit.com/images/profile/defaultProfile_100_female.gif', 'compare' => 'NOT LIKE'))));
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                $displayName = get_post_meta(get_the_id(), 'displayName', true);
                $avatar = get_post_meta(get_the_id(), 'avatar150', true);
                $return .= sprintf('<div class="col-lg-3 col-sm-3 focus-box">
		 								<div class="service-icon">
		 									<i style="background:url(%s) no-repeat center;width:100%%; height:100%%;" class="pixeden"></i>
		 								</div>
		 								<h3 class="red-border-bottom">%s</h3>
		 								<a class="btn btn-primary btn-block green-btn btn-sm" href="https://www.fitbit.com/user/%s"><i class="fa fa-plus"></i> Add Friend</a>
		 								<br/>
		 							</div>', $avatar, $displayName, get_the_title(), get_the_content());
            }
            $return = '<div class="hwd-wrapper"><div class="row">' . $return . '</div></div>';
        } else {
            $return = 'No Friends Found';
        }
        wp_reset_query();
        return $return;
    }
開發者ID:HealthyWebDeveloper,項目名稱:HWD-friend-finder,代碼行數:26,代碼來源:class-friend-shortcode.php

示例9: tf_buddypress

/**
 * Template for BuddyPress pages
 * 
 * @package ThemifyFlow
 * @since 1.0.0
 */
function tf_buddypress()
{
    while (have_posts()) {
        the_post();
        the_content();
    }
}
開發者ID:jhostetter,項目名稱:wp_intern_themes,代碼行數:13,代碼來源:buddypress.php

示例10: skeleton_og_meta_tags

    /**
     * Display the Open Graph meta tags.
     * Add more to this if needed.
     *
     * See: https://developers.facebook.com/docs/sharing/webmasters and http://ogp.me/
     */
    function skeleton_og_meta_tags()
    {
        if (is_single() || is_page()) {
            if (have_posts()) {
                while (have_posts()) {
                    the_post();
                    ?>
        <meta name="og:description" content="<?php 
                    the_excerpt_rss();
                    ?>
">
        <meta name="og:image" content="<?php 
                    echo skeleton_get_thumbnail_src(get_post_thumbnail_id());
                    ?>
">
    <?php 
                }
            }
        } elseif (is_home()) {
            ?>
        <meta name="og:description" content="<?php 
            bloginfo('description');
            ?>
">
    <?php 
        }
    }
開發者ID:sayme,項目名稱:skeleton,代碼行數:33,代碼來源:template-tags.php

示例11: show_faq

function show_faq($atts)
{
    ob_start();
    $secondary_query = new WP_Query(array('post_type' => 'questions', 'posts_per_page' => $atts[limit], 'tax_query' => array(array('taxonomy' => 'faq', 'field' => 'slug', 'terms' => $atts[category], 'operator' => 'IN'))));
    if ($secondary_query->have_posts()) {
        while ($secondary_query->have_posts()) {
            $secondary_query->the_post();
            echo '
								<div class="row">
									<div class="col-lg-8 col-lg-offset-2 centered">
							';
            the_post();
            the_post_thumbnail('thumbnail');
            the_title('<h1>', '</h1>');
            the_content();
            echo '
									</div>
								</div>
							';
        }
        // end while
    }
    // end if
    wp_reset_postdata();
    return ob_get_clean();
}
開發者ID:avikour,項目名稱:myfaq-wordpress-plugin,代碼行數:26,代碼來源:shortcode.php

示例12: widget

 function widget($args, $instance)
 {
     if (!is_home()) {
         return false;
     }
     /*
         Query the first post:
          If it has a featured image, display it,
          and store its ID in an array.
     */
     query_posts('posts_per_page=1');
     while (have_posts()) {
         the_post();
         $do_not_duplicate[] = $post->ID;
         get_template_part('feature', 'index');
     }
     /*
         Excerpt post loop.
          If a #feature post exists, do not duplicate.
     */
     if ((int) $instance['excerpts_count'] > 0) {
         query_posts(array('post__not_in' => $do_not_duplicate, 'offset' => 1, 'posts_per_page' => (int) $instance['excerpts_count']));
         echo '<div class="clearfix">';
         for ($post_count = 1; have_posts(); $post_count++) {
             the_post();
             $do_not_duplicate[] = $post->ID;
             /*
                 See: lib/helpers.php -> sourdough_excerpt()
             */
             sourdough_excerpt($post_count);
         }
         echo '</div>';
     }
     wp_reset_query();
 }
開發者ID:staydecent,項目名稱:wp-sourdough,代碼行數:35,代碼來源:sourdough-featured-posts.php

示例13: get_loadmore

 function get_loadmore()
 {
     global $wp_query;
     if (isset($_REQUEST['nonce']) && wp_verify_nonce($_REQUEST['nonce'], 'load_more')) {
         $post_type = get_query_var('post_type');
         $paged = (int) $_REQUEST['page'];
         $per_page = 5;
         # Check if post_type set as $_REQUEST
         if (isset($_REQUEST['post_type'])) {
             $post_type = $_REQUEST['post_type'];
         }
         if (isset($_REQUEST['per_page'])) {
             $per_page = (int) $_REQUEST['per_page'];
         }
         $args = array('post_type' => $post_type, 'paged' => $paged, 'posts_per_page' => $per_page);
         $wp_query = new WP_Query($args);
         if (have_posts()) {
             while (have_posts()) {
                 the_post();
                 get_template_part('content', get_post_type());
             }
         }
         exit;
     }
 }
開發者ID:AllFamous,項目名稱:singapore-wine-vault,代碼行數:25,代碼來源:init.php

示例14: ae_default_list_post

/**
 * list post with template by default query
 * @since 1.0
 * @author Dakachi
 */
function ae_default_list_post()
{
    global $ae_post_factory;
    if (have_posts()) {
        // post list
        echo '<ul>';
        while (have_posts()) {
            the_post();
            global $post;
            $object = $ae_post_factory->get($post->post_type);
            $convert = $object->convert($post);
            $json_data[] = $convert;
            // get post type item template
            ae_post_template_part('template/loop', $post->post_type);
        }
        echo '</ul>';
        // print js template for post item
        ae_post_template_part('template-js/loop', $post->post_type);
        // print post array json data
        if (!isset($args['json_id'])) {
            $args['json_id'] = 'ae-' . $post->post_type . '-json';
        }
        echo '<script type="json/data" id="' . $args['json_id'] . '"> ' . json_encode($json_data) . '
                </script>';
    }
}
開發者ID:rinodung,項目名稱:wp-question,代碼行數:31,代碼來源:template.php

示例15: zp_custom_blog_page

function zp_custom_blog_page()
{
    global $post, $paged;
    $include = genesis_get_option('blog_cat');
    $exclude = genesis_get_option('blog_cat_exclude') ? explode(',', str_replace(' ', '', genesis_get_option('blog_cat_exclude'))) : '';
    if (get_query_var('paged')) {
        $paged = get_query_var('paged');
    } elseif (get_query_var('page')) {
        $paged = get_query_var('page');
    } else {
        $paged = 1;
    }
    //* Arguments
    $args = array('cat' => $include, 'category__not_in' => $exclude, 'posts_per_page' => genesis_get_option('blog_cat_num'), 'paged' => $paged);
    query_posts($args);
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            do_action('genesis_before_entry');
            printf('<article %s>', genesis_attr('entry'));
            // check post format and call template
            $format = get_post_format();
            get_template_part('content', $format);
            do_action('genesis_after_entry_content');
            //do_action( 'genesis_entry_footer' );
            echo '</article>';
            do_action('genesis_after_entry');
        }
    }
    //* Genesis navigation
    genesis_posts_nav();
    //* Restore original query
    wp_reset_query();
}
開發者ID:lukasalbrecht,項目名稱:www.genesis-playground.dev,代碼行數:34,代碼來源:home.php


注:本文中的the_post函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。