本文整理汇总了PHP中get_post_format函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_format函数的具体用法?PHP get_post_format怎么用?PHP get_post_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_format函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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>';
}
}
}
}
}
}
}
}
}
示例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());
}
}
示例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);
}
示例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());
}
}
示例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());
}
}
示例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']);
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例13: wedge_render_infinite_posts
function wedge_render_infinite_posts()
{
while (have_posts()) {
the_post();
get_template_part('content', get_post_format());
}
}
示例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());
}
}
示例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());
}
}