本文整理汇总了PHP中get_post_class函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_class函数的具体用法?PHP get_post_class怎么用?PHP get_post_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_class函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jellythemes_photos_list
function jellythemes_photos_list($atts, $content = null)
{
extract(shortcode_atts(array('limit' => 8), $atts));
$return = '
<nav class="primary"><ul>
<li><a class="selected" href="#" data-filter="*"><span>' . __('All photos', 'jellythemes') . '</span></a></li>';
$types = get_terms('type', array('hide_empty' => 0));
if ($types && !is_wp_error($types)) {
foreach ($types as $type) {
$return .= '<li><a href="#" data-filter=".' . esc_js($type->slug) . '"><span>' . $type->name . '</span></a></li>';
}
}
$return .= '</ul></nav>
<div class="portfolio">';
$photos = new WP_Query(array('post_type' => 'photo', 'posts_per_page' => esc_attr($limit)));
while ($photos->have_posts()) {
$photos->the_post();
$term_list = wp_get_post_terms(get_the_ID(), 'type', array("fields" => "names"));
$images = rwmb_meta('_jellythemes_project_images', 'type=plupload_image', get_the_ID());
foreach ($images as $image) {
$img = wp_get_attachment_image($image['ID'], 'full', false, array('class' => 'img-responsive'));
$src = wp_get_attachment_image_src($image['ID'], 'full');
}
$return .= '<article class="' . implode(' ', get_post_class('entry')) . '">
<a class="swipebox" href="' . $src[0] . '">
' . $img . '
<span class="magnifier"></span>
</a>
</article>';
}
$return .= '</div>';
return $return;
}
示例2: shortcode_post_teacher
function shortcode_post_teacher($atts, $content)
{
$html = '<div class="tribe-events"><div class="fusion-posts-teacher fusion-blog-layout-grid fusion-blog-layout-grid-4 isotope"><div class="fusion-row">';
$args = array('post_type' => 'post-k-teacher', 'posts_per_page' => 4);
$the_query = new WP_Query($args);
while ($the_query->have_posts()) {
$the_query->the_post();
$html .= '<article id="post-' . get_the_ID() . '" class="' . implode(' ', get_post_class('post fusion-post-grid')) . '"><div class="post-inner">';
if (has_post_thumbnail()) {
$html .= '<div class="entry-thumb">';
$html .= '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail(get_the_ID(), 'rt_thumb300x400') . '</a>';
$html .= '</div>';
}
$html .= '<h3 class="entry-title"><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h3>';
if (function_exists('get_field')) {
$manifesto = get_field('manifesto');
if (!empty($manifesto)) {
$html .= '<div class="entry-manifesto">';
$html .= $manifesto;
$html .= '</div>';
}
}
$html .= '</div></article>';
}
$html .= '</div></div></div>';
return $html;
}
示例3: get_article
/**
* Get Article
*
* Builds the post being displayed by the load_loop function adding clip formatting as required as well as relevant post classes
*
* @uses pagelines_show_clip
* @uses post_header
* @uses post_entry
*
* @internal uses filter 'pagelines_get_article_post_classes'
* @internal uses filter 'pageliens_get_article_output'
*/
function get_article()
{
global $wp_query;
global $post;
/* clip handling */
$clip = $this->pagelines_show_clip($this->count, $this->paged) ? true : false;
$meta_mode = $this->section->opt('pl_meta_mode');
$format = $clip ? 'clip' : 'feature';
$clip_row_start = $this->clipcount % 2 == 0 ? true : false;
$clip_right = ($this->clipcount + 1) % 2 == 0 ? true : false;
$clip_row_end = $clip_right || $this->count == $this->post_count ? true : false;
$post_type_class = $clip ? $clip_right ? 'clip clip-right' : 'clip' : 'fpost';
$meta_mode_class = isset($meta_mode) && $meta_mode != '' ? 'meta-mode-' . $meta_mode : '';
$pagelines_post_classes = apply_filters('pagelines_get_article_post_classes', sprintf('%s post-number-%s', $post_type_class, $this->count));
$post_classes = join(' ', get_post_class($pagelines_post_classes));
$wrap_type = $clip ? 'clip_box' : 'article-wrap';
$wrap_start = $clip && $clip_row_start || !$clip ? sprintf('<div class="%s %s fix">', $wrap_type, $meta_mode_class) : '';
$wrap_end = $clip && $clip_row_end || !$clip ? sprintf('</div>') : '';
$author_tag = !$clip && $meta_mode == 'author' ? $this->get_author_tag() : '';
$post_args = array('header' => $this->post_header($format), 'entry' => $this->post_entry(), 'classes' => $post_classes, 'pad-class' => $clip ? 'hentry-pad blocks' : 'hentry-pad', 'wrap-start' => $wrap_start, 'wrap-end' => $wrap_end, 'format' => $format, 'count' => $this->count);
$post_args['markup-start'] = sprintf('%s<article class="%s" id="post-%s">%s<div class="wrp"><div class="%s">', $post_args['wrap-start'], $post_args['classes'], $post->ID, $author_tag, $post_args['pad-class']);
$post_args['markup-end'] = sprintf('</div></div></article>%s', $post_args['wrap-end']);
$original = join(array($post_args['markup-start'], $post_args['header'], $post_args['entry'], $post_args['markup-end']));
echo apply_filters('pagelines_get_article_output', $original, $post, $post_args);
// Count the clips
if ($clip) {
$this->clipcount++;
}
// Count the posts
$this->count++;
}
示例4: render
public function render($atts, $content = null)
{
$css = '';
extract(shortcode_atts(array('css' => ''), $atts));
$css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, vc_shortcode_custom_css_class($css, ' '));
$events = new WP_Query(array('post_type' => 'event', 'posts_per_page' => 4, 'order' => 'ASC', 'orderby' => 'event_when', 'meta_query' => array(array('key' => 'event_when', 'value' => current_time('timestamp'), 'compare' => '>'))));
$output = '';
if ($events->have_posts()) {
$output .= '<div class="event_list_module ' . $css_class . '">';
$output .= '<ul class="events_list clearfix">';
while ($events->have_posts()) {
$events->the_post();
$output .= '<li id="post-' . get_the_ID() . '" class="' . implode(' ', get_post_class()) . '">';
$output .= '<div class="event-content">';
$output .= '<div class="event-date_wrapper">';
$output .= '<div class="event_top"></div>';
$output .= '<div class="event-date">';
$output .= date('d', get_post_meta(get_the_ID(), 'event_when', true));
$output .= '<span>' . date('F', get_post_meta(get_the_ID(), 'event_when', true)) . '</span>';
$output .= '<div class="event-date-border"></div>';
$output .= '</div>';
$output .= '</div>';
$output .= '<h5><a href="' . get_the_permalink() . '">' . get_the_title() . '</a></h5>';
$output .= '<cite>' . get_post_meta(get_the_ID(), 'event_where', true) . '</cite>';
$output .= '<a href="' . get_the_permalink() . '" class="button">' . __('More Details', STM_DOMAIN) . '</a>';
$output .= '</div>';
$output .= '</li>';
}
$output .= '</ul>';
$output .= '</div>';
}
wp_reset_query();
return $output;
}
示例5: widget
/**
* Display widget content.
*
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
* @param array $instance The settings for the particular instance of the widget
*/
function widget($args, $instance)
{
extract($args);
$instance = wp_parse_args((array) $instance, $this->defaults);
$featured_page = new WP_Query(array('page_id' => $instance['page_id']));
echo $before_widget . '<div class="feature-page">';
if (!empty($instance['title'])) {
echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
}
if ($featured_page->have_posts()) {
while ($featured_page->have_posts()) {
$featured_page->the_post();
echo '<div class="' . implode(' ', get_post_class()) . '">';
if (!empty($instance['show_title'])) {
printf('<h4 class="entry-title"><a href="%s" title="%s">%s</a></h4>', get_permalink(), the_title_attribute('echo=0'), get_the_title());
}
//Show image
if (!empty($instance['show_image'])) {
printf('<a href="%s" title="%s" class="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), calibrefx_get_image(array('format' => 'html', 'size' => $instance['image_size'])));
}
if (!empty($instance['show_content'])) {
if (empty($instance['content_limit'])) {
the_content($instance['more_text']);
} else {
the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
}
}
echo '</div><!--end post_class()-->' . "\n\n";
}
}
echo '</div>' . $after_widget;
wp_reset_query();
}
示例6: get_post_classes
function get_post_classes($object, $field_name, $request)
{
setup_get_field($object, $field_name, $request);
$post_class = get_post_class();
$post_class = join(' ', $post_class);
return $post_class;
}
示例7: grahlie_use_pages
/**
* Output pages defined in framework
*/
function grahlie_use_pages($class = null, $title, $thumbnail)
{
$grahlie_values = get_option('grahlie_framework_values');
$output = '';
if (array_key_exists('use_pages', $grahlie_values) && $grahlie_values['use_pages'] == 'on' && array_key_exists('use_pages_count', $grahlie_values)) {
for ($i = 1; $i <= $grahlie_values['use_pages_count']; $i++) {
$page = get_post($grahlie_values['use_pages_select'][$i]);
$size = 'size' . 12 / $grahlie_values['use_pages_count'];
$id = get_post_class()[0];
$type = get_post_class()[1];
$class .= ' ' . $id . ' ' . $type . ' column';
$output .= '<div id="' . $id . '" class="grahlieBox' . $class . ' ' . $size . '">';
if ($thumb != '') {
$thumb = get_the_post_thumbnail($page->ID);
$output .= $thumb;
}
if ($title != '') {
$output .= '<h2>' . $page->post_title . '</h2>';
}
if (empty($page->post_excerpt)) {
$content = grahlie_content_excerpt_filter($page->post_content);
} else {
$content = $page->post_excerpt;
}
$output .= '<p>' . $content . '</p><a href="' . $page->post_name . '" class="btn btn-primary">Läs mer</a></div>';
}
}
return $output;
}
示例8: wpsc_get_product_class
function wpsc_get_product_class($class, $post_id = null)
{
if (!$post_id) {
$post_id = wpsc_get_product_id();
}
return get_post_class($class, $post_id);
}
示例9: widget
/**
* Echo the widget content.
*
* @since 0.1.8
*
* @global WP_Query $wp_query Query object.
* @global integer $more
*
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
* @param array $instance The settings for the particular instance of the widget
*/
function widget($args, $instance)
{
//* Merge with defaults
$instance = wp_parse_args((array) $instance, $this->defaults);
if (!empty($instance['url'])) {
$instance['url'] = do_shortcode($instance['url']);
}
if (!empty($instance['image_url'])) {
$instance['image_url'] = do_shortcode($instance['image_url']);
}
if (!empty($instance['description'])) {
$instance['description'] = do_shortcode($instance['description']);
}
echo $args['before_widget'];
if (!empty($instance['title'])) {
echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['after_title'];
}
genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
if (!empty($instance['url'])) {
echo '<a href="' . $instance['url'] . '" title="' . $instance['title'] . '" class="' . esc_attr($instance['image_alignment']) . '">' . '<img src="' . $instance['image_url'] . '" class="entry-image" itemprop="image" />' . '</a>';
}
if (!empty($instance['description'])) {
echo genesis_html5() ? '<div class="entry-content">' : '';
echo esc_html($instance['description']);
echo genesis_html5() ? '</div>' : '';
}
genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
echo $args['after_widget'];
}
示例10: getWordpressData
static function getWordpressData() {
/**
* Get all global page data
*/
$blogDataParams = array(
'url', 'wpurl', 'description', 'rdf_url' , 'rss_url', 'rss2_url'
, 'atom_url', 'comments_atom_url', 'comments_rss2_url', 'pingback_url'
, 'stylesheet_url', 'stylesheet_directory', 'template_directory'
, 'template_url', 'admin_email', 'charset', 'html_type', 'version'
, 'language', 'text_direction', 'name'
);
$blogData = array();
foreach($blogDataParams as $blogDataParam) {
$blogData[self::toCamelCase($blogDataParam)] = get_bloginfo($blogDataParam);
}
$blogData = array_merge($blogData, array(
'title' => wp_title(' | ', false, 'right') . get_bloginfo('name'),
'archiveLinksHTML' => wp_get_archives('type=monthly&limit=5&format=link&echo=0'),
'bodyClasses' => self::getEchoFunctionContents('body_class'),
'posts' => array()
));
/**
* Get posts data
*/
while (have_posts()) {
the_post();
$postId = get_the_ID();
// Get category data
$categories = get_the_category();
$categoryNames = array();
foreach($categories as $category) {
array_push($categoryNames, $category->cat_name);
}
// Add all relevant post data to the posts array
array_push(
$blogData['posts'],
array_merge(
get_object_vars(get_post($postId)),
array(
'classes' => get_post_class(),
'comments' => get_comments(array('post_id' => $postId)),
'custom' => get_post_custom(),
'permalink' => get_permalink(),
'categories' => $categories,
'categoryNames' => $categoryNames,
'categoriesStr' => implode(',', $categoryNames)
)
)
);
}
return $blogData;
}
示例11: sc_get_events_list
function sc_get_events_list($display = 'all', $category = null, $number = 5)
{
$event_args = array('post_type' => 'sc_event', 'posts_per_page' => $number, 'meta_key' => 'sc_event_date_time', 'orderby' => 'meta_value_num', 'order' => 'asc', 'post_status' => 'publish');
if ($display == 'past') {
$event_args['meta_compare'] = '<';
$event_args['order'] = 'desc';
} else {
if ($display == 'upcoming') {
$event_args['meta_compare'] = '>=';
}
}
if ($display != 'all') {
$event_args['meta_value'] = time();
}
if (!is_null($category)) {
$event_args['sc_event_category'] = $category;
}
$events = get_posts(apply_filters('sc_event_list_query', $event_args));
ob_start();
if ($events) {
echo '<ul class="sc_events_list">';
foreach ($events as $event) {
echo '<li class="' . str_replace('hentry', '', implode(' ', get_post_class('sc_event', $event->ID))) . '">';
do_action('sc_before_event_list_item', $event->ID);
echo '<a href="' . get_permalink($event->ID) . '" class="sc_event_link">';
echo '<span class="sc_event_title">' . get_the_title($event->ID) . '</span>';
echo '</a>';
do_action('sc_after_event_list_item', $event->ID);
echo '</li>';
}
echo '</ul>';
}
return ob_get_clean();
}
示例12: theme_latest_news
function theme_latest_news($atts, $content)
{
global $themename;
extract(shortcode_atts(array("count" => 2, "category" => "", "order" => "DESC"), $atts));
query_posts(array('post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $count, 'cat' => $category, 'order' => $order));
$output = '<ul class="blog clearfix">';
if (have_posts()) {
while (have_posts()) {
the_post();
$post_classes = get_post_class("post");
$output .= '<li class="';
foreach ($post_classes as $key => $post_class) {
$output .= $post_class . ($key + 1 < count($post_classes) ? ' ' : '');
}
$output .= '">
<div class="comment_box">
<div class="first_row">
' . get_the_time("d") . '<span class="second_row">' . strtoupper(get_the_time("M")) . '</span>
</div>';
$comments_count = get_comments_number();
$output .= ' <a class="comments_number" href="' . get_comments_link() . '" title="' . $comments_count . ($comments_count == 1 ? ' ' . __('Comment', $themename) : ' ' . __('Comments', $themename)) . '">' . $comments_count . ($comments_count == 1 ? ' ' . __('Comment', $themename) : ' ' . __('Comments', $themename)) . '</a>
</div>
<div class="post_content">';
if (has_post_thumbnail()) {
$output .= '<a class="post_image" href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail(get_the_ID(), "blog-post-thumb", array("alt" => get_the_title(), "title" => "")) . '</a>';
}
$output .= ' <h2>
<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a>
</h2>
<div class="text">
' . apply_filters('the_excerpt', get_the_excerpt()) . '
</div>
<div class="post_footer">
<ul class="categories">
<li class="posted_by">' . __('Posted by', $themename) . ' <a class="author" href="' . get_the_author_link() . '" title="' . get_the_author() . '">' . get_the_author() . '</a></li>';
$categories = get_the_category();
foreach ($categories as $key => $category) {
$output .= '<li>
<a href="' . get_category_link($category->term_id) . '" ';
if (empty($category->description)) {
$output .= 'title="' . sprintf(__('View all posts filed under %s', $themename), $category->name) . '"';
} else {
$output .= 'title="' . esc_attr(strip_tags(apply_filters('category_description', $category->description, $category))) . '"';
}
$output .= '>' . $category->name . '</a>
</li>';
}
$output .= ' </ul>
<a class="more icon_small_arrow margin_right_white" href="' . get_permalink() . '" title="' . __("More", $themename) . '">' . __("More", $themename) . '</a>
</div>
</div>
</li>';
}
}
$output .= '</ul>';
//Reset Query
wp_reset_query();
return $output;
}
示例13: widget
/**
* Echo the widget content.
*
* @since 0.1.8
*
* @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
* @param array $instance The settings for the particular instance of the widget
*/
function widget($args, $instance)
{
global $wp_query, $_genesis_displayed_ids;
extract($args);
// Merge with defaults
$instance = wp_parse_args((array) $instance, $this->defaults);
echo $before_widget;
if (!empty($instance['title'])) {
echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
}
$query_args = array('post_type' => 'listing', 'taxonomy' => $instance['taxonomy'], 'showposts' => $instance['posts_num'], 'offset' => $instance['posts_offset'], 'orderby' => $instance['orderby'], 'order' => $instance['order']);
// Exclude displayed IDs from this loop?
global $post;
$wp_query = new WP_Query($query_args);
if (have_posts()) {
while (have_posts()) {
the_post();
$_genesis_displayed_ids[] = get_the_ID();
genesis_markup(array('html5' => '<article %s><div class="listing-wrap">', 'xhtml' => sprintf('<div class="%s"><div class="listing-wrap">', implode(' ', get_post_class())), 'context' => 'entry'));
$image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
if ($instance['show_image']) {
if ($image) {
printf('<a href="%s" alt="%s">%s</a>', esc_url(get_permalink()), esc_attr(the_title_attribute('echo=0')), wp_kses_post($image));
} else {
$fallback = plugins_url('includes/sample-images/simple-listings.png', dirname(__FILE__));
printf('<a href="%s"><img src="%s" alt="%s" />', esc_url(get_permalink()), esc_url($fallback), esc_attr(the_title_attribute('echo=0')));
}
}
if ($instance['show_title']) {
echo genesis_html5() ? '<header class="entry-header">' : '';
}
if (!empty($instance['show_title'])) {
printf('<h2 class="entry-title">%s</h2>', the_title_attribute('echo=0'), get_the_title());
}
if (!empty($instance['show_status'])) {
echo '<span class="listing-status">' . strip_tags(get_the_term_list($post->ID, 'status', '', ', ', '')) . '</span>';
}
if ($instance['show_title']) {
echo genesis_html5() ? '</header>' : '';
}
if (!empty($instance['show_content'])) {
echo genesis_html5() ? '<div class="entry-content">' : '';
global $more;
$orig_more = $more;
$more = 0;
the_content(esc_html($instance['more_text']));
$more = $orig_more;
echo genesis_html5() ? '</div>' : '';
}
genesis_markup(array('html5' => '</div></article>', 'xhtml' => '</div></div>'));
}
}
if (!empty($instance['archive_link']) && !empty($instance['archive_text'])) {
printf('<p class="more-from-category"><a href="%1$s">%2$s</a></p>', esc_url(get_post_type_archive_link($instance['post_type'])), esc_html($instance['archive_text']));
}
// Restore original query
wp_reset_query();
echo $after_widget;
}
示例14: get_post_data
function get_post_data($post_object)
{
global $post;
$post = $post_object;
setup_postdata($post);
$post_class = get_post_class();
$post_data = array('author' => get_the_author(), 'author_url' => get_author_posts_url(get_the_author_meta('ID')), 'classes' => join(' ', $post_class), 'content' => get_the_content(), 'date' => get_the_date(), 'datetime' => get_post_time('c', true), 'excerpt' => get_the_excerpt(), 'json_url' => '/wp-json/wp/v2/posts/' . get_the_ID(), 'title' => get_the_title(), 'link' => str_replace(home_url(), '', get_the_permalink()));
return $post_data;
}
示例15: widget
function widget($args, $instance)
{
/** defaults */
$instance = wp_parse_args($instance, array('title' => '', 'posts_per_page' => 10));
extract($args);
echo $before_widget;
if (!empty($instance['title'])) {
echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
}
$toggle = '';
/** for left/right class */
$query_args = array('post_type' => 'listing', 'posts_per_page' => $instance['posts_per_page'], 'paged' => get_query_var('paged') ? get_query_var('paged') : 1);
query_posts($query_args);
if (have_posts()) {
while (have_posts()) {
the_post();
//* initialze the $loop variable
$loop = '';
//* Pull all the listing information
$custom_text = genesis_get_custom_field('_listing_text');
$price = genesis_get_custom_field('_listing_price');
$address = genesis_get_custom_field('_listing_address');
$city = genesis_get_custom_field('_listing_city');
$state = genesis_get_custom_field('_listing_state');
$zip = genesis_get_custom_field('_listing_zip');
$loop .= sprintf('<a href="%s">%s</a>', get_permalink(), genesis_get_image(array('size' => 'properties')));
if ($price) {
$loop .= sprintf('<span class="listing-price">%s</span>', $price);
}
if (strlen($custom_text)) {
$loop .= sprintf('<span class="listing-text">%s</span>', esc_html($custom_text));
}
if ($address) {
$loop .= sprintf('<span class="listing-address">%s</span>', $address);
}
if ($city || $state || $zip) {
//* count number of completed fields
$pass = count(array_filter(array($city, $state, $zip)));
//* If only 1 field filled out, no comma
if (1 == $pass) {
$city_state_zip = $city . $state . $zip;
} elseif ($city) {
$city_state_zip = $city . ", " . $state . " " . $zip;
} else {
$city_state_zip = $city . " " . $state . ", " . $zip;
}
$loop .= sprintf('<span class="listing-city-state-zip">%s</span>', trim($city_state_zip));
}
$loop .= sprintf('<a href="%s" class="more-link">%s</a>', get_permalink(), __('View Listing', 'agentpress-listings'));
$toggle = $toggle == 'left' ? 'right' : 'left';
/** wrap in post class div, and output **/
printf('<div class="%s"><div class="widget-wrap"><div class="listing-wrap">%s</div></div></div>', join(' ', get_post_class($toggle)), apply_filters('agentpress_featured_listings_widget_loop', $loop));
}
}
wp_reset_query();
echo $after_widget;
}