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