本文整理汇总了PHP中get_the_title函数的典型用法代码示例。如果您正苦于以下问题:PHP get_the_title函数的具体用法?PHP get_the_title怎么用?PHP get_the_title使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_the_title函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: widget
function widget($args, $instance)
{
global $post;
extract($args, EXTR_SKIP);
echo $before_widget;
$title = empty($instance['title']) ? __('Recent Posts', 'lan-thinkupthemes') : apply_filters('widget_title', $instance['title']);
if (!empty($title)) {
echo $before_title . $title . $after_title;
}
$posts = new WP_Query('orderby=date&posts_per_page=' . $instance['postcount'] . '');
while ($posts->have_posts()) {
$posts->the_post();
// Insert post date if needed.
if ($instance['postdate'] == 'on') {
$date_input = '<a href="' . get_permalink() . '" class="date">' . get_the_date('M j, Y') . '</a>';
}
// HTML output
echo '<div class="recent-posts">';
if (has_post_thumbnail() and $instance['imageswitch'] == 'on') {
echo '<div class="image">', '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, array(65, 65)) . '<div class="image-overlay"></div></a>', '</div>', '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
} else {
echo '<div class="main">', '<a href="' . get_permalink() . '">' . get_the_title() . '</a>', $date_input, '</div>';
}
echo '</div>';
}
wp_reset_query();
echo $after_widget;
}
开发者ID:closings,项目名称:closings,代码行数:28,代码来源:recentposts.php
示例2: pricetable
/**
*
*/
public static function pricetable($atts, $content = null, $code = null)
{
if ($atts == 'generator') {
global $wpdb;
$prices_list = array();
$pricetables = $wpdb->get_results('SELECT ID, post_title FROM ' . $wpdb->posts . ' WHERE post_type = "pricetable"');
if (is_array($pricetables)) {
foreach ($pricetables as $key => $value) {
$prices_list[$value->ID] = $pricetables[$key]->post_title;
}
} else {
$price_list[0] = __('Please install Price Table plugin...', MISS_ADMIN_TEXTDOMAIN);
}
$option = array('name' => __('Blog Grid Layout', MISS_ADMIN_TEXTDOMAIN), 'value' => 'pricetable', 'options' => array(array('name' => __('Select Table', MISS_ADMIN_TEXTDOMAIN), 'desc' => __('Choose "Pricing Table" to use.', MISS_ADMIN_TEXTDOMAIN), 'id' => 'id', 'type' => 'select', 'options' => $prices_list), 'shortcode_has_atts' => true));
return $option;
}
extract(shortcode_atts(array('id' => ''), $atts));
$pricetable = new WP_Query();
$pricetable->query(array('post_type' => 'pricetable', 'post_id' => $id));
while ($pricetable->have_posts()) {
$pricetable->the_post();
$prices_list[get_the_ID()] = get_the_title();
$out = '[price_table id="' . $id . '"]';
}
return do_shortcode($out);
}
开发者ID:schiz,项目名称:scrollax,代码行数:29,代码来源:pricetable.php
示例3: blog_summary_shortcode
function blog_summary_shortcode($attr)
{
// Describes what attributes to parse from shortcode; only 'count'
extract(shortcode_atts(array('count' => '5', 'grouptag' => 'ul', 'entrytag' => 'li', 'titletag' => 'h4', 'datetag' => 'span', 'commentstag' => 'span', 'summarytag' => 'div'), $attr));
// Queries to populate our loop based on shortcode count attribute
$r = new WP_Query("showposts={$count}&what_to_show=posts&nopaging=0&post_status=publish");
// Only run if we have posts; can't run this through searches
if ($r->have_posts() && !is_search()) {
// If we're using a Sandbox-friendly theme . . .
if (function_exists('sandbox_body_class')) {
// We can't have double hfeed classes, otherwise it won't parse
$groupclasses = 'xoxo';
} else {
// Otherwise, use hfeed to ensure hAtom compliance
$groupclasses = 'xoxo hfeed';
}
// Begin the output for shortcode and inserts in the group tag what classes we have
$output = '<' . $grouptag . ' class="' . $groupclasses . '">';
// Begins our loop for returning posts
while ($r->have_posts()) {
// Sets which post from our loop we're at
$r->the_post();
// Allows the_date() with multiple posts within a single day
unset($previousday);
// If we're using a Sandbox-friendly theme . . .
if (function_exists('sandbox_post_class')) {
// Let's use semantic classes with each entry element
$entryclasses = sandbox_post_class(false);
} else {
// Otherwise, use hentry to ensure hAtom compliance
$entryclasses = 'hentry';
}
// Begin entry wrapper and inserts what classes we got from above
$output .= "\n" . '<' . $entrytag . ' class="' . $entryclasses . '">';
// Post title
$output .= "\n" . '<' . $titletag . ' class="entry-title"><a href="' . get_permalink() . '" title="' . sprintf(__('Permalink to %s', 'blog_summary'), the_title_attribute('echo=0')) . '" rel="bookmark">' . get_the_title() . '</a></' . $titletag . '>';
// Post date with hAtom support
$output .= "\n" . '<' . $datetag . ' class="entry-date"><abbr class="published" title="' . get_the_time('Y-m-d\\TH:i:sO') . '">' . sprintf(__('%s', 'blog_summary'), the_date('', '', '', false)) . '</abbr></' . $datetag . '>';
// Comments number
$output .= "\n" . '<' . $commentstag . ' class="entry-comments"><a href="' . get_permalink() . '#comments" title="' . sprintf(__('Comments to %s', 'blog_summary'), the_title_attribute('echo=0')) . '">' . sprintf(__('Comments (%s)', 'blog_summary'), apply_filters('comments_number', get_comments_number())) . '</a></' . $commentstag . '>';
// Post excerpt with hAtom support
$output .= "\n" . '<' . $summarytag . ' class="entry-summary">' . "\n" . apply_filters('the_excerpt', get_the_excerpt()) . '</' . $summarytag . '>';
// Close each post LI
$output .= "\n" . '</' . $entrytag . '>';
// Finish the have_posts() query
}
// while ( $r->have_posts() ) :
// Close the parent UL
$output .= "\n" . '</' . $grouptag . '>';
// Rewinds loop from $r->the_post();
rewind_posts();
// End the initial IF statement
}
// if ( $r->have_posts() ) :
// Clears our query to put the loop back where it was
wp_reset_query();
// $r = new WP_Query()
// Returns $output to the shortcode
return $output;
}
开发者ID:Turante,项目名称:wp-plugin-dev,代码行数:60,代码来源:blog-summary.php
示例4: ajax_create_slide
/**
* Create a new slide and echo the admin HTML
*/
public function ajax_create_slide()
{
// security check
if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'metaslider_addslide')) {
echo "<tr><td colspan='2'>" . __("Security check failed. Refresh page and try again.", 'metaslider') . "</td></tr>";
die;
}
$slider_id = absint($_POST['slider_id']);
$selection = $_POST['selection'];
if (is_array($selection) && count($selection) && $slider_id > 0) {
foreach ($selection as $slide_id) {
$this->set_slide($slide_id);
$this->set_slider($slider_id);
if ($this->slide_exists_in_slideshow($slider_id, $slide_id)) {
echo "<tr><td colspan='2'>ID: {$slide_id} \"" . get_the_title($slide_id) . "\" - " . __("Failed to add slide. Slide already exists in slideshow.", 'metaslider') . "</td></tr>";
} else {
if (!$this->slide_is_unassigned_or_image_slide($slider_id, $slide_id)) {
echo "<tr><td colspan='2'>ID: {$slide_id} \"" . get_the_title($slide_id) . "\" - " . __("Failed to add slide. Slide is not of type 'image'.", 'metaslider') . "</td></tr>";
} else {
$this->tag_slide_to_slider();
$this->add_or_update_or_delete_meta($slide_id, 'type', 'image');
// override the width and height to kick off the AJAX image resizing on save
$this->settings['width'] = 0;
$this->settings['height'] = 0;
echo $this->get_admin_slide();
}
}
}
}
die;
}
开发者ID:pradeep-web,项目名称:brandt,代码行数:34,代码来源:metaslide.image.class.php
示例5: totc_children
function totc_children($atts)
{
global $post;
global $more;
$more = 0;
$return = "";
$oldpost = $post;
if ($post->ID) {
$args = array('post_parent' => $post->ID, 'post_type' => 'page', 'orderby' => 'date', 'order' => 'DESC');
$children = get_posts($args);
if ($children) {
foreach ($children as $post) {
setup_postdata($post);
$more = 0;
$content = get_the_content('');
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$return .= '<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>
' . $content;
}
}
}
setup_postdata($oldpost);
return $return;
}
开发者ID:Ruxton,项目名称:ToTC,代码行数:25,代码来源:totc.php
示例6: rum_post_cta_meta_box_list
function rum_post_cta_meta_box_list()
{
global $post;
// store global post object for later resetting after our query
// using wp_reset_postdata() doesn't work so we are manually resetting the global
$post_old = $post;
// initialize variables
$options = '';
// get plugin option array and store in a variable
$plugin_option_array = get_option('rum_post_cta_plugin_options');
// fetch values from the plugin option variable array
$post_cta_post_type = $plugin_option_array['post_type'];
// retrieve the custom meta box value
$post_cta_id = get_post_meta($post->ID, 'rum_post_cta_id', true);
// set query arguments
$args = array('post_type' => $post_cta_post_type, 'nopaging' => true);
// execute the query
$cta_post_query = new WP_Query($args);
// The Loop
while ($cta_post_query->have_posts()) {
$cta_post_query->the_post();
$post_title = get_the_title();
$post_ID = get_the_id();
$options .= '<option value="' . esc_attr($post_ID) . '" ' . selected($post_cta_id, $post_ID) . '>' . $post_title . '</option>';
}
// restore the global $post variable of the main query loop
// wp_reset_postdata(); doesn't work so we are manually resetting it back
// restore global post object
$post = $post_old;
setup_postdata($post);
return $options;
}
开发者ID:rumspeed,项目名称:post-call-to-action,代码行数:32,代码来源:metabox.php
示例7: image_cpt_shortcode
function image_cpt_shortcode($attr)
{
if ($attr['page'] <= 10) {
$per_page['page'] = $attr['page'];
} else {
$per_page['page'] = 10;
}
$output = '<h2 class="winner-title">Hall of Winners</h2><h3 class="winner-subtitle">Congratulations to all of our winners</h3>';
$args = array('post_type' => 'image_post_type', 'posts_per_page' => $per_page['page']);
$loop = new WP_query($args);
if ($loop->have_posts()) {
while ($loop->have_posts()) {
$loop->the_post();
$output .= '<div class="winner-div"><h3>';
$output .= get_the_title();
$output .= '</h3>';
if (has_post_thumbnail()) {
// check if the post has a post thumbnail assigned to it.
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id($loop->ID), 'full');
$url = $thumb['0'];
$output .= '<img src="' . $url . '"/>';
}
$output .= '</div>';
}
} else {
// if no content, include the "no posts found" template.
get_template_part('content', 'none');
}
return $output;
}
开发者ID:Shane-McCarthy,项目名称:wordpress-custom-theme,代码行数:30,代码来源:functions.php
示例8: novalite_get_title
/**
* Wp in Progress
*
* @author WPinProgress
*
* This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
* It is also available at this URL: http://www.gnu.org/licenses/gpl-3.0.txt
*/
function novalite_get_title()
{
global $post;
$title = get_the_title();
if (!empty($title)) {
if (is_home() || is_category() || is_search()) {
?>
<h3 class="title"> <a href="<?php
echo get_permalink($post->ID);
?>
"> <?php
echo $title;
?>
</a> </h3>
<?php
} else {
?>
<h1 class="title"> <?php
echo $title;
?>
</h1>
<?php
}
}
}
开发者ID:f0rg3,项目名称:salvation-army,代码行数:37,代码来源:title.php
示例9: miss_image_signature
/**
* Returning Image Information Array
* @since 1.5
*/
function miss_image_signature($thumb)
{
if (get_post_meta(get_the_ID(), 'app_lightbox', true) == "yes" && get_post_meta(get_the_ID(), 'app_embed', true) != "") {
$link = array('href' => get_post_meta(get_the_ID(), 'app_embed', true), 'title' => get_the_title(), 'class' => "prettyPhoto");
$img = array('src' => $thumb, 'alt' => sprintf(__("%1{$s} on Youtube", MISS_TEXTDOMAIN), get_the_title()), 'title' => sprintf(__("Watch %1{$s} on Youtube", MISS_TEXTDOMAIN), get_the_title()), 'class' => "image-resize w loadOnVisible");
} else {
if (get_post_meta(get_the_ID(), '_image', true)) {
$link = array('href' => get_post_meta(get_the_ID(), '_image', true), 'title' => get_the_title(), 'class' => "prettyPhoto");
$img = array('src' => $thumb, 'alt' => sprintf(__('Open Image %1$s', MISS_TEXTDOMAIN), get_the_title()), 'title' => sprintf(__('Show %1$s', MISS_TEXTDOMAIN), get_the_title()), 'class' => "image-resize w loadOnVisible");
} else {
if (get_post_meta(get_the_ID(), 'app_lightbox', true) == "no" && get_post_meta(get_the_ID(), 'app_embed', true) == "") {
$link = array('href' => get_permalink(), 'title' => get_the_title(), 'class' => "pic");
$img = array('src' => $thumb, 'alt' => sprintf(__('Find Out More About %1$s', MISS_TEXTDOMAIN), get_the_title()), 'title' => sprintf(__('Find Out More', MISS_TEXTDOMAIN), get_the_title()), 'class' => "image-resize w loadOnVisible");
} else {
if (get_post_meta(get_the_ID(), 'app_lightbox', true) == "no" && get_post_meta(get_the_ID(), 'app_embed', true) != "") {
$link = array('href' => get_permalink(), 'title' => get_the_title(), 'class' => "video");
$img = array('src' => $thumb, 'alt' => sprintf(__('Find Out More About %1$s', MISS_TEXTDOMAIN), get_the_title()), 'title' => sprintf(__('Find Out More', MISS_TEXTDOMAIN), get_the_title()), 'class' => "image-resize w loadOnVisible");
} else {
$link = array('href' => get_permalink(), 'title' => get_the_title(), 'class' => "pic");
$img = array('src' => $thumb, 'alt' => sprintf(__('Find Out More About %1$s', MISS_TEXTDOMAIN), get_the_title()), 'title' => sprintf(__('Find Out More', MISS_TEXTDOMAIN), get_the_title()), 'class' => "image-resize w loadOnVisible");
}
}
}
}
return array('link' => $link, 'img' => $img);
}
开发者ID:schiz,项目名称:scrollax,代码行数:30,代码来源:image.php
示例10: get_data
/**
* Compile the schema.org event data into an array
*/
public function get_data($post = null, $args = array())
{
if (!$post instanceof WP_Post) {
$post = Tribe__Main::post_id_helper($post);
}
$post = get_post($post);
if (!$post instanceof WP_Post) {
return array();
}
$data = (object) array();
// We may need to prevent the context to be triggered
if (!isset($args['context']) || false !== $args['context']) {
$data->{'@context'} = 'http://schema.org';
}
$data->{'@type'} = $this->type;
$data->name = esc_js(get_the_title($post));
$data->description = esc_js(tribe_events_get_the_excerpt($post));
if (has_post_thumbnail($post)) {
$data->image = wp_get_attachment_url(get_post_thumbnail_id($post));
}
$data->url = esc_url_raw(get_permalink($post));
// Index by ID: this will allow filter code to identify the actual event being referred to
// without injecting an additional property
return array($post->ID => $data);
}
开发者ID:nullify005,项目名称:shcc-website,代码行数:28,代码来源:Abstract.php
示例11: wpml_link_to_element
function wpml_link_to_element($element_id, $element_type = 'post', $link_text = '', $optional_parameters = array(), $anchor = '', $echoit = true)
{
if (!function_exists('icl_link_to_element')) {
switch ($element_type) {
case 'post':
case 'page':
$ret = '<a href="' . get_permalink($element_id) . '">';
if ($anchor) {
$ret .= $anchor;
} else {
$ret .= get_the_title($element_id);
}
$ret .= '<a>';
break;
case 'tag':
case 'post_tag':
$tag = get_term_by('id', $element_id, 'tag', ARRAY_A);
$ret = '<a href="' . get_tag_link($element_id) . '">' . $tag->name . '</a>';
case 'category':
$ret = '<a href="' . get_tag_link($element_id) . '">' . get_the_category_by_ID($element_id) . '</a>';
default:
$ret = '';
}
if ($echoit) {
echo $ret;
} else {
return $ret;
}
} else {
return icl_link_to_element($element_id, $element_type, $link_text, $optional_parameters, $anchor, $echoit);
}
}
开发者ID:StudioCreate,项目名称:Uncle-Hummer-WordPress-Theme,代码行数:32,代码来源:wpml-integration.php
示例12: 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
示例13: spring_title
/**
* Page titles
*/
function spring_title()
{
if (is_home()) {
if (get_option('page_for_posts', true)) {
return get_the_title(get_option('page_for_posts', true));
} else {
return __('Latest Posts', 'spring-theme');
}
} elseif (is_archive()) {
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if ($term) {
return apply_filters('single_term_title', $term->name);
} elseif (is_post_type_archive()) {
return apply_filters('the_title', get_queried_object()->labels->name);
} elseif (is_day()) {
return sprintf(__('Daily Archives: %s', 'spring-theme'), get_the_date());
} elseif (is_month()) {
return sprintf(__('Monthly Archives: %s', 'spring-theme'), get_the_date('F Y'));
} elseif (is_year()) {
return sprintf(__('Yearly Archives: %s', 'spring-theme'), get_the_date('Y'));
} elseif (is_author()) {
$author = get_queried_object();
return sprintf(__('Author Archives: %s', 'spring-theme'), $author->display_name);
} else {
return single_cat_title('', false);
}
} elseif (is_search()) {
return sprintf(__('Search Results for %s', 'spring-theme'), get_search_query());
} elseif (is_404()) {
return __('Not Found', 'spring-theme');
} else {
return get_the_title();
}
}
开发者ID:marktimemedia,项目名称:mtm-theme,代码行数:37,代码来源:titles.php
示例14: forms_dropdown
/**
* Renders an HTML Dropdown of all the Give Forms
*
* @access public
* @since 1.0
*
* @param array $args Arguments for the dropdown
*
* @return string $output Give forms dropdown
*/
public function forms_dropdown($args = array())
{
$defaults = array('name' => 'forms', 'id' => 'forms', 'class' => '', 'multiple' => false, 'selected' => 0, 'chosen' => false, 'number' => 30, 'placeholder' => sprintf(__('Select a %s', 'give'), give_get_forms_label_singular()));
$args = wp_parse_args($args, $defaults);
$forms = get_posts(array('post_type' => 'give_forms', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => $args['number']));
$options = array();
if ($forms) {
$options[0] = sprintf(__('Select a %s', 'give'), give_get_forms_label_singular());
foreach ($forms as $form) {
$options[absint($form->ID)] = esc_html($form->post_title);
}
} else {
$options[0] = __('No Give Forms Found', 'give');
}
// This ensures that any selected forms are included in the drop down
if (is_array($args['selected'])) {
foreach ($args['selected'] as $item) {
if (!in_array($item, $options)) {
$options[$item] = get_the_title($item);
}
}
} elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
if (!in_array($args['selected'], $options)) {
$options[$args['selected']] = get_the_title($args['selected']);
}
}
$output = $this->select(array('name' => $args['name'], 'selected' => $args['selected'], 'id' => $args['id'], 'class' => $args['class'], 'options' => $options, 'chosen' => $args['chosen'], 'multiple' => $args['multiple'], 'placeholder' => $args['placeholder'], 'show_option_all' => false, 'show_option_none' => false));
return $output;
}
开发者ID:duongnguyen92,项目名称:tvd12v2,代码行数:39,代码来源:class-give-html-elements.php
示例15: woocommerce_order_get_items
function woocommerce_order_get_items($items)
{
if (isset($_GET['post']) && get_post_type($_GET['post']) == 'shop_order') {
global $sitepress_settings;
foreach ($items as $index => $item) {
foreach ($item as $key => $item_data) {
if ($key == 'product_id') {
$tr_product_id = apply_filters('translate_object_id', $item_data, 'product', false, $sitepress_settings['admin_default_language']);
if (!is_null($tr_product_id)) {
$items[$index][$key] = $tr_product_id;
$items[$index]['name'] = get_the_title($tr_product_id);
}
}
if ($key == 'variation_id') {
$tr_variation_id = apply_filters('translate_object_id', $item_data, 'product_variation', false, $sitepress_settings['admin_default_language']);
if (!is_null($tr_variation_id)) {
$items[$index][$key] = $tr_variation_id;
}
}
if (substr($key, 0, 3) == 'pa_') {
global $wpdb, $woocommerce_wpml;
//attr is taxonomy
$term_id = $woocommerce_wpml->products->wcml_get_term_id_by_slug($key, $item_data);
$tr_id = apply_filters('translate_object_id', $term_id, $key, false, $sitepress_settings['admin_default_language']);
if (!is_null($tr_id)) {
$translated_slug = $wpdb->get_var($wpdb->prepare("\r\n SELECT t.slug FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $key));
$items[$index][$key] = $translated_slug;
}
}
}
}
}
return $items;
}
开发者ID:mahirziyaokan,项目名称:woocommerce-multilingual,代码行数:34,代码来源:orders.class.php
示例16: ap_page_title
/**
* Return current page title
* @return string current title
*/
function ap_page_title()
{
$pages = anspress()->pages;
$current_page = get_query_var('ap_page');
if (is_question()) {
$new_title = ap_question_title_with_solved_prefix();
} elseif (is_ap_edit()) {
$new_title = __('Edit post', 'ap');
} elseif (is_ap_search()) {
$new_title = sprintf(ap_opt('search_page_title'), sanitize_text_field(get_query_var('ap_s')));
} elseif (is_ask()) {
$new_title = ap_opt('ask_page_title');
} elseif (is_ap_users()) {
$new_title = ap_opt('users_page_title');
} elseif ($current_page == '' && !is_question() && get_query_var('question_name') == '') {
$new_title = ap_opt('base_page_title');
} elseif (get_query_var('parent') != '') {
$new_title = sprintf(__('Discussion on "%s"', 'ap'), get_the_title(get_query_var('parent')));
} elseif (isset($pages[$current_page]['title'])) {
$new_title = $pages[$current_page]['title'];
} else {
$new_title = __('Error 404', 'ap');
}
$new_title = apply_filters('ap_page_title', $new_title);
return $new_title;
}
开发者ID:haythameyd,项目名称:powrly,代码行数:30,代码来源:theme.php
示例17: widget
/**
* Default widget front end display method.
*
* @since 1.0.0
*
* @param array $args Args specific to the widget area (sidebar).
* @param array $instance Widget instance settings.
*/
function widget($args, $instance)
{
extract($args);
$instance['title_raw'] = $instance['title'];
$instance['title'] = apply_filters('widget_title', empty($instance['title']) ? get_the_title($instance['post_id']) : $instance['title'], $instance, $this->id_base);
$instance['title'] = apply_filters('audiotheme_widget_title', $instance['title'], $instance, $args, $this->id_base);
echo $before_widget;
// Output filter is for backwards compatibility.
if ($output = apply_filters('audiotheme_widget_video_output', '', $instance, $args)) {
echo empty($instance['title']) ? '' : $before_title . $instance['title'] . $after_title;
echo $output;
} else {
$post = get_post($instance['post_id']);
$image_size = apply_filters('audiotheme_widget_video_image_size', 'thumbnail', $instance, $args);
$image_size = apply_filters('audiotheme_widget_video_image_size-' . $args['id'], $image_size, $instance, $args);
$data = array();
$data['args'] = $args;
$data['after_title'] = $args['after_title'];
$data['before_title'] = $args['before_title'];
$data['image_size'] = $image_size;
$data['post'] = get_post($instance['post_id']);
$data = array_merge($instance, $data);
$template = audiotheme_locate_template(array("widgets/{$args['id']}_video.php", 'widgets/video.php'));
audiotheme_load_template($template, $data);
}
echo $after_widget;
}
开发者ID:sewmyheadon,项目名称:audiotheme,代码行数:35,代码来源:video.php
示例18: getRecent
/**
* Latest blog posts
*
* @param int $limit post display limit
*
* @param string $thumbnail_size
*
* @return array
*/
public static function getRecent($limit = 10, $thumbnail_size = 'thumbnail')
{
$args = array('numberposts' => $limit, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending', 'suppress_filters' => true);
$array_out = array();
$recent_posts = \get_posts(\wp_parse_args($args));
/*$like_bool = Option::get_theme_option( 'blog_list_like' );
if ( $like_bool === '1' ) {
$PostLike = \SilverWp\Ajax\PostLike::getInstance();
}*/
foreach ($recent_posts as $key => $recent) {
\setup_postdata($recent);
$post_id = $recent->ID;
//$array_out[ $key ] = $recent;
$array_out[$key]['ID'] = $post_id;
$array_out[$key]['post_title'] = \get_the_title($post_id);
$array_out[$key]['url'] = \get_the_permalink($post_id);
$array_out[$key]['post_author'] = \get_the_author();
$array_out[$key]['post_date'] = \get_the_date('', $post_id);
$array_out[$key]['post_date_utc'] = \get_the_time('c', $post_id);
//$array_out[ $key ]['post_like'] = ($like_bool === '1') ? $PostLike->getPostLikeCount($post_id) : '';
$array_out[$key]['post_comment_count'] = $recent->comment_count;
if (strpos($recent->post_content, '<!--more-->') || empty($recent->post_excerpt)) {
$array_out[$key]['post_excerpt'] = \get_the_excerpt();
} else {
$array_out[$key]['post_excerpt'] = $recent->post_excerpt;
}
$array_out[$key]['image_html'] = \get_the_post_thumbnail($post_id, $thumbnail_size);
// Thumbnail
$array_out[$key]['categories'] = self::getTaxonomy($post_id);
}
\wp_reset_postdata();
return $array_out;
}
开发者ID:silversite,项目名称:silverwp,代码行数:42,代码来源:Post.php
示例19: al_portfolio_meta_tags
function al_portfolio_meta_tags()
{
$post_type = get_post_type();
if ('portfolio' == $post_type) {
$title = get_post_meta(get_the_ID(), "al_pf_og_title", TRUE);
$title = !empty($title) ? $title : get_the_title();
$meta = array('og:title' => $title, 'og:url' => get_permalink());
$desc = get_post_meta(get_the_ID(), "al_pf_og_description", TRUE);
$desc = !empty($desc) ? $desc : false;
if ($desc) {
$meta['og:description'] = $desc;
}
if (has_post_thumbnail()) {
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
$meta['og:image'] = $thumbnail[0];
}
if (get_post_format() == 'gallery') {
$images = rwmb_meta('al_pf_gallery_images', 'type=image&size=full');
if (is_array($images)) {
foreach ($images as $image) {
$meta['images'][] = $image['url'];
}
}
}
foreach ($meta as $key => $value) {
if ($key == 'images') {
foreach ($value as $image) {
echo '<meta property="og:image" content="' . $image . '" />';
}
} else {
echo '<meta property="' . $key . '" content="' . $value . '" />';
}
}
}
}
开发者ID:azeemgolive,项目名称:thefunkidsgame,代码行数:35,代码来源:artless-portfolio.php
示例20: widget
public function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
if (!empty($title)) {
echo $before_title . $title . $after_title;
}
$numberposts = isset($instance['numberposts']) ? $instance['numberposts'] : 1;
$termargs = array('post_type' => 'glossary', 'post_status' => 'publish', 'numberposts' => $numberposts, 'orderby' => 'rand');
if ($group = $instance['group']) {
$termargs['tax_query'] = array(array('taxonomy' => 'wpglossarygroup', 'field' => 'slug', 'terms' => $group));
}
$terms = get_posts($termargs);
if ($terms && count($terms)) {
echo '<ul class="wpglossary widget-list">';
foreach ($terms as $term) {
setup_postdata($term);
$title = '<a href="' . apply_filters('wpg_term_link', get_post_permalink($term->ID)) . '">' . get_the_title($term->ID) . '</a>';
$desc = '';
$display = $instance['display'];
if ($display && $display != 'title') {
$desc = $display == 'full' ? apply_filters('the_content', get_the_content(), $main = false) : wpautop(get_the_excerpt());
$desc = '<br>' . $desc;
}
echo '<li>' . $title . $desc . '</li>';
}
wp_reset_postdata();
echo '</ul>';
} else {
echo '<em>' . __('No terms available', 'wp-glossary') . '</em>';
}
echo $after_widget;
}
开发者ID:s3rgiosan,项目名称:WP-Glossary,代码行数:34,代码来源:wpg-widget-random-term.class.php
注:本文中的get_the_title函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论