本文整理汇总了PHP中get_post_format函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_format函数的具体用法?PHP get_post_format怎么用?PHP get_post_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_format函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: hybrid_get_content_template
/**
* Loads a post content template based off the post type and/or the post format. This functionality is
* not feasible with the WordPress get_template_part() function, so we have to rely on some custom logic
* and locate_template().
*
* Note that using this function assumes that you're creating a content template to handle attachments.
* This filter must be removed since we're bypassing the WP template hierarchy and focusing on templates
* specific to the content.
*
* @since 1.6.0
* @access public
* @return string
*/
function hybrid_get_content_template()
{
/* Set up an empty array and get the post type. */
$templates = array();
$post_type = get_post_type();
/* Assume the theme developer is creating an attachment template. */
if ('attachment' === $post_type) {
remove_filter('the_content', 'prepend_attachment');
$mime_type = get_post_mime_type();
list($type, $subtype) = false !== strpos($mime_type, '/') ? explode('/', $mime_type) : array($mime_type, '');
$templates[] = "content-attachment-{$type}.php";
$templates[] = "content/attachment-{$type}.php";
}
/* If the post type supports 'post-formats', get the template based on the format. */
if (post_type_supports($post_type, 'post-formats')) {
/* Get the post format. */
$post_format = get_post_format() ? get_post_format() : 'standard';
/* Template based off post type and post format. */
$templates[] = "content-{$post_type}-{$post_format}.php";
$templates[] = "content/{$post_type}-{$post_format}.php";
/* Template based off the post format. */
$templates[] = "content-{$post_format}.php";
$templates[] = "content/{$post_format}.php";
}
/* Template based off the post type. */
$templates[] = "content-{$post_type}.php";
$templates[] = "content/{$post_type}.php";
/* Fallback 'content.php' template. */
$templates[] = 'content.php';
$templates[] = 'content/content.php';
/* Allow devs to filter the content template hierarchy. */
$templates = apply_filters('hybrid_content_template_hierarchy', $templates);
/* Apply filters and return the found content template. */
include apply_filters('hybrid_content_template', locate_template($templates, false, false));
}
开发者ID:highergroundstudio,项目名称:hybrid-core,代码行数:48,代码来源:template.php
示例2: thinkup_input_blogformat
function thinkup_input_blogformat()
{
if (get_post_format() == 'gallery') {
echo '<div class="blog-icon gallery"><a href="' . get_permalink() . '"><i class="icon-picture icon-large"></i></a></div>';
} else {
if (get_post_format() == 'image') {
echo '<div class="blog-icon image"><a href="' . get_permalink() . '"><i class="icon-picture icon-large"></i></a></div>';
} else {
if (get_post_format() == 'video') {
echo '<div class="blog-icon video"><a href="' . get_permalink() . '"><i class="icon-film icon-large"></i></a></div>';
} else {
if (get_post_format() == 'audio') {
echo '<div class="blog-icon audio"><a href="' . get_permalink() . '"><i class="icon-volume-up icon-large"></i></a></div>';
} else {
if (get_post_format() == 'status') {
echo '<div class="blog-icon status"><a href="' . get_permalink() . '"><i class="icon-rss icon-large"></i></a></div>';
} else {
if (get_post_format() == 'quote') {
echo '<div class="blog-icon quote"><a href="' . get_permalink() . '"><i class="icon-quote-left icon-large"></i></a></div>';
} else {
if (get_post_format() == 'link') {
echo '<div class="blog-icon link"><a href="' . get_permalink() . '"><i class="icon-link icon-large"></i></a></div>';
} else {
if (get_post_format() == 'chat') {
echo '<div class="blog-icon chat"><a href="' . get_permalink() . '"><i class="icon-comment-alt icon-large"></i></a></div>';
}
}
}
}
}
}
}
}
}
开发者ID:nvvetal,项目名称:water,代码行数:34,代码来源:05.blog.php
示例3: brewery_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function brewery_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
开发者ID:ehoanshelt,项目名称:BullCreek,代码行数:10,代码来源:jetpack.php
示例4: tc_post_content
/**
* The default template for displaying single post content
*
* @package Customizr
* @since Customizr 3.0
*/
function tc_post_content()
{
//check conditional tags : we want to show single post or single custom post types
global $post;
$tc_show_single_post_content = isset($post) && 'page' != $post->post_type && 'attachment' != $post->post_type && is_singular() && !tc__f('__is_home_empty');
if (!apply_filters('tc_show_single_post_content', $tc_show_single_post_content)) {
return;
}
//display an icon for div if there is no title
$icon_class = in_array(get_post_format(), array('quote', 'aside', 'status', 'link')) ? apply_filters('tc_post_format_icon', 'format-icon') : '';
ob_start();
do_action('__before_content');
?>
<section class="entry-content <?php
echo $icon_class;
?>
">
<?php
the_content(__('Continue reading <span class="meta-nav">→</span>', 'customizr'));
?>
<?php
wp_link_pages(array('before' => '<div class="pagination pagination-centered">' . __('Pages:', 'customizr'), 'after' => '</div>'));
?>
</section><!-- .entry-content -->
<?php
do_action('__after_content');
$html = ob_get_contents();
if ($html) {
ob_end_clean();
}
echo apply_filters('tc_post_content', $html);
}
开发者ID:andrewfandrew,项目名称:bronze-boar,代码行数:41,代码来源:class-content-post.php
示例5: 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
示例6: 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
示例7: check_get_post_response
protected function check_get_post_response($response, $post_obj, $context = 'view')
{
$response = json_ensure_response($response);
$response_data = $response->get_data();
$this->assertEquals($post_obj->ID, $response_data['ID']);
$this->assertEquals($post_obj->post_name, $response_data['slug']);
$this->assertEquals($post_obj->post_status, $response_data['status']);
$this->assertEquals($post_obj->post_author, $response_data['author']);
$this->assertArrayHasKey('parent', $response_data);
$this->assertEquals(get_permalink($post_obj->ID), $response_data['link']);
$this->assertEquals($post_obj->menu_order, $response_data['menu_order']);
$this->assertEquals($post_obj->comment_status, $response_data['comment_status']);
$this->assertEquals($post_obj->ping_status, $response_data['ping_status']);
$this->assertEquals($post_obj->post_password, $response_data['password']);
$this->assertEquals(is_sticky($post_obj->ID), $response_data['sticky']);
// Check post parent.
if ($post_obj->post_parent) {
if (is_int($response_data['parent'])) {
$this->assertEquals($post_obj->post_parent, $response_data['parent']);
} else {
$this->assertEquals($post_obj->post_parent, $response_data['parent']['ID']);
$this->check_get_post_response($response_data['parent'], get_post($response_data['parent']['ID']), 'view-parent');
}
} else {
$this->assertEmpty($response_data['parent']);
}
// Check post format.
$post_format = get_post_format($post_obj->ID);
if (empty($post_format)) {
$this->assertEquals('standard', $response_data['format']);
} else {
$this->assertEquals(get_post_format($post_obj->ID), $response_data['format']);
}
// Check post dates.
if ($post_obj->post_date_gmt === '0000-00-00 00:00:00') {
$this->assertNull($response_data['date']);
$this->assertNull($response_data['date_gmt']);
} else {
$this->assertEquals(json_mysql_to_rfc3339($post_obj->post_date), $response_data['date']);
$this->assertEquals(json_mysql_to_rfc3339($post_obj->post_date_gmt), $response_data['date_gmt']);
}
if ($post_obj->post_modified_gmt === '0000-00-00 00:00:00') {
$this->assertNull($response_data['modified']);
$this->assertNull($response_data['modified_gmt']);
} else {
$this->assertEquals(json_mysql_to_rfc3339($post_obj->post_modified), $response_data['modified']);
$this->assertEquals(json_mysql_to_rfc3339($post_obj->post_modified_gmt), $response_data['modified_gmt']);
}
// Check filtered values.
$this->assertEquals(get_the_title($post_obj->ID), $response_data['title']);
// TODO: apply content filter for more accurate testing.
$this->assertEquals(wpautop($post_obj->post_content), $response_data['content']);
// TODO: apply excerpt filter for more accurate testing.
$this->assertEquals(wpautop($post_obj->post_excerpt), $response_data['excerpt']);
$this->assertEquals($post_obj->guid, $response_data['guid']);
if ($context === 'edit') {
$this->assertEquals($post_obj->post_content, $response_data['content_raw']);
$this->assertEquals($post_obj->post_excerpt, $response_data['excerpt_raw']);
}
}
开发者ID:NicholasTaylorUK,项目名称:WP-API,代码行数:60,代码来源:test-json-posts.php
示例8: abc_nuorisotominta_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function abc_nuorisotominta_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
开发者ID:aleksandr-fishchenko,项目名称:abc-nuorisotoiminta-wordpress-theme,代码行数:10,代码来源:jetpack.php
示例9: tabula_rasa_owlandpeaock_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function tabula_rasa_owlandpeaock_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
开发者ID:kennytheecat,项目名称:tabula-rasa-owlandpeaock,代码行数:10,代码来源:jetpack.php
示例10: sensitive_skin_bootstrap_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function sensitive_skin_bootstrap_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
开发者ID:bmeisler,项目名称:ssm-bootstrap,代码行数:10,代码来源:jetpack.php
示例11: chomarat_2015_theme_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function chomarat_2015_theme_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
开发者ID:Jean-Bernard,项目名称:proj,代码行数:10,代码来源:jetpack.php
示例12: heisenberg_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function heisenberg_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('page-templates/content', get_post_format());
}
}
开发者ID:perceptions,项目名称:epicpew,代码行数:10,代码来源:jetpack.php
示例13: wedge_render_infinite_posts
function wedge_render_infinite_posts()
{
while (have_posts()) {
the_post();
get_template_part('content', get_post_format());
}
}
开发者ID:lionax,项目名称:wp-wedge,代码行数:7,代码来源:jetpack.php
示例14: devpro_theme_by_benjamin_knecht_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function devpro_theme_by_benjamin_knecht_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
开发者ID:benblub,项目名称:wordpress-bootstrap-theme-by-benjamin-knecht,代码行数:10,代码来源:jetpack.php
示例15: privacyhorisontheme_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function privacyhorisontheme_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
开发者ID:AgentEm,项目名称:privacyhorizontheme,代码行数:10,代码来源:jetpack.php
示例16: mcclellandinsurance_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function mcclellandinsurance_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
开发者ID:kristencodes,项目名称:so-special,代码行数:10,代码来源:jetpack.php
示例17: 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
示例18: wpsp_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function wpsp_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('partials/content', get_post_format());
}
}
开发者ID:sptheme,项目名称:klahan9,代码行数:10,代码来源:jetpack.php
示例19: theme_posts_shortcode
/**
* Shortcode functionality to show posts.
*
* @since 1.0.0
*/
function theme_posts_shortcode($atts)
{
$output = false;
// Pull in shortcode attributes and set defaults
$defaults = array('category' => '', 'order' => 'DESC', 'orderby' => 'date', 'posts_per_page' => '10', 'tag' => '');
// Process shortcode attribtues
$atts = shortcode_atts($defaults, $atts, 'show-posts');
// Set up initial query for post
$args = array('category_name' => $atts['category'], 'order' => $atts['order'], 'orderby' => $atts['orderby'], 'posts_per_page' => $atts['posts_per_page'], 'tag' => $atts['tag'], 'ignore_sticky_posts' => 1, 'no_found_rows' => true);
$query = new WP_Query($args);
if ($query->have_posts()) {
global $wp_query;
// Backup the main query.
$saved_query = $wp_query;
// Replace the main query by reference.
$wp_query = $query;
// Capture the output so we can return it to the shortcode process.
ob_start();
echo '<div class="show-posts-wrapper">';
while ($wp_query->have_posts()) {
$wp_query->the_post();
get_template_part('content', get_post_format());
}
echo '</div>';
$output = ob_get_clean();
// Clean up after ourselves.
$wp_query = $saved_query;
wp_reset_postdata();
}
return $output;
}
开发者ID:joemcgill,项目名称:Theme-Posts-Shortcode,代码行数:36,代码来源:theme-posts-shortcode.php
示例20: redemptive_developments_infinite_scroll_render
/**
* Custom render function for Infinite Scroll.
*/
function redemptive_developments_infinite_scroll_render()
{
while (have_posts()) {
the_post();
get_template_part('template-parts/content', get_post_format());
}
}
开发者ID:ethicalux,项目名称:redemptive-developments-revert,代码行数:10,代码来源:jetpack.php
注:本文中的get_post_format函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论