当前位置: 首页>>代码示例>>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;未经允许,请勿转载。