本文整理汇总了PHP中get_the_content函数的典型用法代码示例。如果您正苦于以下问题:PHP get_the_content函数的具体用法?PHP get_the_content怎么用?PHP get_the_content使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_the_content函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_the_content_with_formatting
/**
* Get content with formatting in place
* @param type $more_link_text
* @param type $stripteaser
* @param type $more_file
* @return type
*/
function get_the_content_with_formatting($more_link_text = '(more...)', $stripteaser = 0)
{
$content = get_the_content($more_link_text, $stripteaser);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return $content;
}
开发者ID:junander,项目名称:playground,代码行数:14,代码来源:persistent-funcs.php
示例2: 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
示例3: the_content
function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '')
{
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:7,代码来源:post-template.php
示例4: the_content_rss
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content_rss', $content);
if ( $cut && !$encode_html )
$encode_html = 2;
if ( 1== $encode_html ) {
$content = wp_specialchars($content);
$cut = 0;
} elseif ( 0 == $encode_html ) {
$content = make_url_footnote($content);
} elseif ( 2 == $encode_html ) {
$content = strip_tags($content);
}
if ( $cut ) {
$blah = explode(' ', $content);
if ( count($blah) > $cut ) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
for ( $i=0; $i<$k; $i++ )
$excerpt .= $blah[$i].' ';
$excerpt .= ($use_dotdotdot) ? '...' : '';
$content = $excerpt;
}
$content = str_replace(']]>', ']]>', $content);
echo $content;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:30,代码来源:feed.php
示例5: 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
示例6: mantra_trim_excerpt
/**
* Allows post excerpts to contain HTML tags
* @since mantra 1.8.7
* @return string Excerpt with most HTML tags intact
*/
function mantra_trim_excerpt($text)
{
global $mantra_excerptwords;
global $mantra_excerptcont;
global $mantra_excerptdots;
$raw_excerpt = $text;
if ('' == $text) {
//Retrieve the post content.
$text = get_the_content('');
//Delete all shortcode tags from the content.
$text = strip_shortcodes($text);
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$allowed_tags = '<a>,<img>,<b>,<strong>,<ul>,<li>,<i>,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>,<pre>,<code>,<em>,<u>,<br>,<p>';
$text = strip_tags($text, $allowed_tags);
$words = preg_split("/[\n\r\t ]+/", $text, $mantra_excerptwords + 1, PREG_SPLIT_NO_EMPTY);
if (count($words) > $mantra_excerptwords) {
array_pop($words);
$text = implode(' ', $words);
$text = $text . ' ' . $mantra_excerptdots . ' <a href="' . get_permalink() . '">' . $mantra_excerptcont . ' <span class="meta-nav">→ </span>' . '</a>';
} else {
$text = implode(' ', $words);
}
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
开发者ID:rzb,项目名称:boletos2,代码行数:31,代码来源:theme-loop.php
示例7: red_wp_trim_excerpt
/**
* Customize excerpt length and style.
*
* @param string The raw post content.
* @return string
*/
function red_wp_trim_excerpt($text)
{
$raw_excerpt = $text;
if ('' == $text) {
// retrieve the post content
$text = get_the_content('');
// delete all shortcode tags from the content
$text = strip_shortcodes($text);
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
// indicate allowable tags
$allowed_tags = '<p>,<a>,<em>,<strong>,<blockquote>,<cite>';
$text = strip_tags($text, $allowed_tags);
// change to desired word count
$excerpt_word_count = 50;
$excerpt_length = apply_filters('excerpt_length', $excerpt_word_count);
// create a custom "more" link
$excerpt_end = '<span>[...]</span><p><a href="' . get_permalink() . '" class="read-more">Read more →</a></p>';
// modify excerpt ending
$excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end);
// add the elipsis and link to the end if the word count is longer than the excerpt
$words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
if (count($words) > $excerpt_length) {
array_pop($words);
$text = implode(' ', $words);
$text = $text . $excerpt_more;
} else {
$text = implode(' ', $words);
}
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
开发者ID:araw604,项目名称:redBread_proj_5,代码行数:38,代码来源:extras.php
示例8: get_the_content_limit
function get_the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '')
{
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('get_the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = strip_tags($content);
if (strlen($_GET['p']) > 0) {
echo $content;
} else {
if (strlen($content) > $max_char && ($espacio = strpos($content, " ", $max_char))) {
$content = substr($content, 0, $espacio);
$content = $content;
echo $content;
//echo "<a href='";
//the_permalink();
echo "...";
echo "<br>";
echo "<div class=";
echo "'read-more'>";
echo "<a href='";
the_permalink();
echo "'>" . $more_link_text . "</a></div></p>";
} else {
echo $content;
}
}
}
开发者ID:tlandn,项目名称:akvo-web,代码行数:27,代码来源:limit-post.php
示例9: the_content_limit
function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '', $echo = true)
{
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = strip_tags($content);
if (strlen($_GET['p']) > 0 && $thisshouldnotapply) {
echo $content;
} else {
if (strlen($content) > $max_char && ($espacio = strpos($content, " ", $max_char))) {
$content = substr($content, 0, $espacio);
if ($echo == true) {
echo $content . "...";
} else {
return $content;
}
} else {
if ($echo == true) {
echo $content . "...";
} else {
return $content;
}
}
}
}
开发者ID:MBerguer,项目名称:wp-demo,代码行数:25,代码来源:functions.php
示例10: efs_get_slider
function efs_get_slider()
{
/**Options Array...to be added on admin later...*/
$showTitle = true;
$showText = true;
$beforeTitle = "<strong>";
$afterTitle = "</strong>";
$slider = '<div class="flexslider contain">
<ul class="slides">';
$efs_query = "post_type=slider-image";
query_posts($efs_query);
if (have_posts()) {
while (have_posts()) {
the_post();
$img = get_the_post_thumbnail($post->ID, 'large');
$slider .= '<li>' . $img;
if ($showTitle || $showText) {
$slider .= '<p class="flex-caption">';
$slider .= $showTitle ? $beforeTitle . get_the_title() . $afterTitle : '';
$slider .= $showText ? '<br/>' . get_the_content() : '';
$slider .= '</p>';
}
$slider .= '</li>';
}
}
wp_reset_query();
$slider .= '</ul>
</div>';
return $slider;
}
开发者ID:v0j,项目名称:envato-flex-slider,代码行数:30,代码来源:envato-flex-slider.php
示例11: shortcode
public function shortcode($atts, $content = null)
{
global $post;
if ('dt_benefits' == get_post_type()) {
return '';
}
self::$shortcodes_count++;
$this->sanitize_attributes($atts);
$output = '';
$dt_query = $this->get_posts_by_terms($this->atts);
if ($dt_query->have_posts()) {
$this->backup_post_object();
$benefits = '';
while ($dt_query->have_posts()) {
$dt_query->the_post();
$benefit_attr = $this->get_benefit_data();
$benefit_content = apply_filters('the_content', get_the_content(''));
$benefits .= $this->render_benefit($benefit_attr, $benefit_content);
}
$this->restore_post_object();
$output .= '<section id="' . $this->get_shortcode_id() . '" ' . $this->get_container_html_class('benefits-grid wf-container') . $this->get_conatiner_data_attributes() . '>';
$output .= $this->get_inline_stylesheet();
$output .= $benefits;
$output .= '</section>';
}
return $output;
}
开发者ID:armslee,项目名称:wp_requid,代码行数:27,代码来源:benefits-vc.php
示例12: content
function content($car = 800, $post_id=null){
$disc = get_the_content($post_id);
if(strlen($disc) > $car){
$disc = substr($disc, 0, $car).'...';
}
echo $disc;
}
开发者ID:jeffesonmaia,项目名称:Api-WordPress,代码行数:7,代码来源:12+-+FUNÇÕES+FUNDAMENTAIS+WORDPRESS.php
示例13: get_the_content_our_way
function get_the_content_our_way($more, $strip_teaser)
{
if (!in_category(array('tylerdibiasio', 'mishatownsend', 'korwinbriggs', 'twogirls', 'thefinerthings'))) {
$content = get_the_content($more, $strip_teaser);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
return "{$content}";
} else {
//get the category
if (in_category('tylerdibiasio')) {
$href = "<a href=\"" . get_option('siteurl') . "/category/tylerdibiasio\">";
} elseif (in_category('mishatownsend')) {
$href = "<a href=\"" . get_option('siteurl') . "/category/mishatownsend\">";
} elseif (in_category('korwinbriggs')) {
$href = "<a href=\"" . get_option('siteurl') . "/category/korwinbriggs\">";
} elseif (in_category('twogirls')) {
$href = "<a href=\"" . get_option('siteurl') . "/category/twogirls\">";
} elseif (in_category('thefinerthings')) {
$href = "<a href=\"" . get_option('siteurl') . "/category/thefinerthings\">";
}
$content = get_the_content($more, $strip_teaser);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = preg_replace('/(.*)(<a.*?href.*?\\>)/is', "\\1{$href}", $content);
return "{$content}";
}
}
开发者ID:robotsintheskies,项目名称:newspaper-2,代码行数:27,代码来源:functions.php
示例14: init_slides
protected function init_slides(WP_Query $query)
{
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$slide = new stdClass();
$post_id = get_the_ID();
$slide->image_src = wp_get_attachment_image_src($post_id, 'full');
$slide->image_alt = get_post_meta($post_id, '_wp_attachment_image_alt', true);
$slide->link = get_post_meta($post_id, 'dt-img-link', true);
$slide->video_url = get_post_meta($post_id, 'dt-video-url', true);
$slide->share_icons = $this->get_slide_share_buttons();
// hide title
if (get_post_meta($post_id, 'dt-img-hide-title', true)) {
$slide->title = '';
} else {
$slide->title = get_the_title();
}
$slide->description = get_the_content();
$slide->id = $post_id;
$this->slides[] = $slide;
}
wp_reset_postdata();
}
// have_posts
}
开发者ID:10asfar,项目名称:WordPress-the7-theme-demo-,代码行数:26,代码来源:presscore-photoscroller.class.php
示例15: nest_custom_excerpt
function nest_custom_excerpt($length_callback = '', $more_callback = '')
{
global $post;
$content = get_the_content();
$trimmed_content = wp_trim_words($content, $length_callback, '... <a class="more" href="' . get_permalink() . '">' . $more_callback . '</a>');
echo $trimmed_content;
}
开发者ID:bigwing,项目名称:nest-starter-theme,代码行数:7,代码来源:utility-functions.php
示例16: widget
/**
* widget function.
*
* @see WP_Widget
* @access public
* @param array $args
* @param array $instance
* @return void
*/
function widget($args, $instance)
{
if ($this->get_cached_widget($args)) {
return;
}
global $job_manager;
extract($args);
if ('' == get_the_content()) {
return;
}
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
$icon = isset($instance['icon']) ? $instance['icon'] : null;
if ($icon) {
$before_title = sprintf($before_title, 'ion-' . $icon);
}
ob_start();
echo $before_widget;
remove_filter('the_content', array($job_manager->post_types, 'job_content'));
if ($title) {
echo $before_title . $title . $after_title;
}
do_action('listify_widget_job_listing_content_before');
the_content();
$listing_title = get_the_title();
echo '<table class="table table-no-border"><tr><td colspan="3"><span class="labelHeading">About HobbyGaze</span></td></tr><tr><td colspan="3">HobbyGaze is an online portal to help you discover places where you can do things you truly love. Whether you want to learn new skills, have fun time with friends or get fit, you can find all these places on HobbyGaze. In the fun category, you can find places for paintball, laser tagging, bowling, go- karting, amusement parks and so on. In the fitness category, you can find gyms, yoga studios, fitness studios, dance, zumba, etc. In the learning category, you will find places for learning arts like singing, painting, dancing. HobbyGaze also lists places to learn new languages, sports etc.<br/>So the next time when you are confused about what to do in your free time, just checkout HobbyGaze and spend your time in a meaningful, satisfactory way! This is the HobbyGaze listing of ' . $listing_title . '</td></tr></table>';
do_action('listify_widget_job_listing_content_after');
echo $after_widget;
$content = ob_get_clean();
echo apply_filters($this->widget_id, $content);
$this->cache_widget($args, $content);
}
开发者ID:Hobbygaze,项目名称:wp,代码行数:40,代码来源:class-widget-job_listing-content.php
示例17: service_shortcode
function service_shortcode($atts)
{
extract(shortcode_atts(array('category' => '', 'type' => '', 'sitem' => ''), $atts, 'wishlist'));
$service_return = '';
$service_return .= '<div class="container"><div class="row">';
$q = new WP_Query(array('post_type' => array('service'), 'post_status' => array('publish'), 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => $sitem, 'service-category' => $category));
$service_return = '<div class="item active">';
while ($q->have_posts()) {
$q->the_post();
//$idz = get_the_ID();
$icon = get_post_meta(get_the_ID(), 'serviceIcon', true);
if ($icon != '' && $icon != 1) {
$ico = 'fa ' . $icon;
} else {
$ico = 'fa fa-bomb';
}
$service_return .= '
<div class="col-md-3 col-sm-6 wow zoomIn text-center" data-wow-duration="700ms" data-wow-delay="300ms">
<div class="service-icon">
<i class="' . $ico . '"></i>
</div>
<div class="service-text">
<h4>' . get_the_title() . '</h4>
<p>' . substr(get_the_content(), 0, 150) . '</p>
</div>
</div>
';
}
$service_return .= '</div>';
wp_reset_query();
$service_return .= '</div>';
return $service_return;
}
开发者ID:EmmaTope,项目名称:Ekaruz-main,代码行数:35,代码来源:tw-service.php
示例18: message
/**
A nice shortcode to output a table of cookies you have saved, output in ascending
alphabetical order. If there are no cookie records found a single empty row is shown.
You can customise the 'not shown' message (see commented code below)
N.B. This only shows the information you entered on the "cookie" admin page, it
does not necessarily mean you comply with the cookie law. It is up to you, or
the website owner, to make sure you have conducted an appropriate cookie audit
and are informing website visitors of the actual cookies that are being stored.
Usage: [cookie_audit]
[cookie_audit style="winter"]
[cookie_audit not_shown_message="No records found"]
[cookie_audit style="winter" not_shown_message="Not found"]
Styles included: simple, classic, modern, rounded, elegant, winter.
Default style applied: classic.
Additional styles: You can customise the CSS by editing the CSS file itself,
included with plugin.
*/
function cookielawinfo_table_shortcode($atts)
{
/** RICHARDASHBY EDIT: only add CSS if table is being used */
wp_enqueue_style('cookielawinfo-table-style');
/** END EDIT */
extract(shortcode_atts(array('style' => 'classic', 'not_shown_message' => ''), $atts));
global $post;
$args = array('post_type' => 'cookielawinfo', 'posts_per_page' => 50, 'order' => 'ASC', 'orderby' => 'title');
$cookies = new WP_Query($args);
$ret = '<table class="cookielawinfo-' . $style . '"><thead><tr>';
$ret .= '<th class="cookielawinfo-column-1">Cookie</th>';
$ret .= '<th class="cookielawinfo-column-2">Type</th>';
$ret .= '<th class="cookielawinfo-column-3">Duration</th>';
$ret .= '<th class="cookielawinfo-column-4">Description</th></tr>';
$ret .= '</thead><tbody>';
if (!$cookies->have_posts()) {
$ret .= '<tr class="cookielawinfo-row"><td colspan="2" class="cookielawinfo-column-empty">' . $not_shown_message . '</td></tr>';
}
while ($cookies->have_posts()) {
$cookies->the_post();
// Get custom fields:
$custom = get_post_custom($post->ID);
$cookie_type = isset($custom["_cli_cookie_type"][0]) ? $custom["_cli_cookie_type"][0] : '';
$cookie_duration = isset($custom["_cli_cookie_duration"][0]) ? $custom["_cli_cookie_duration"][0] : '';
// Output HTML:
$ret .= '<tr class="cookielawinfo-row"><td class="cookielawinfo-column-1">' . get_the_title() . '</td>';
$ret .= '<td class="cookielawinfo-column-2">' . $cookie_type . '</td>';
$ret .= '<td class="cookielawinfo-column-3">' . $cookie_duration . '</td>';
$ret .= '<td class="cookielawinfo-column-4">' . get_the_content() . '</td>';
$ret .= '</tr>';
}
$ret .= '</tbody></table>';
return $ret;
}
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:55,代码来源:shortcodes.php
示例19: esquire_image_grabber
/**
* Return the HTML output for first image found for a post.
*
* @param int post_id ID for parent post
* @param string the_content
* @param string before Optional before string
* @param string after Optional after string
* @return boolean|string HTML output or false if no match
*/
function esquire_image_grabber( $post_id, $the_content = '', $before = '', $after = '' ) {
global $wpdb;
$image_src = '';
if ( empty( $the_content ) )
$the_content = get_the_content();
$first_image = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'attachment' AND INSTR(post_mime_type, 'image') ORDER BY menu_order ASC LIMIT 0,1", (int) $post_id ) );
if ( ! empty( $first_image ) ) {
// We have an attachment, so just use its data.
$image_src = wp_get_attachment_image( $first_image, 'image' );
} else {
// Try to get the image for the linked image (not attached)
$output = preg_match( WPCOM_THEMES_IMAGE_REGEX, $the_content, $matches );
if ( isset( $matches[0] ) )
$image_src = $matches[0];
}
if ( ! empty( $image_src ) ) {
// Add wrapper markup, if specified
if ( ! empty( $before ) )
$image_src = $before . $image_src;
if ( ! empty( $after ) )
$image_src = $image_src . $after;
return $image_src;
}
return false;
}
开发者ID:kevinreilly,项目名称:mendelements.com,代码行数:39,代码来源:content-grabbers.php
示例20: bambule_grab_url
function bambule_grab_url()
{
if (!preg_match('/<a\\s[^>]*?href=[\'"](.+?)[\'"]/i', get_the_content(), $links)) {
return false;
}
return esc_url_raw($links[1]);
}
开发者ID:bambuleger,项目名称:bambule,代码行数:7,代码来源:general-functions.php
注:本文中的get_the_content函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论