当前位置: 首页>>代码示例>>PHP>>正文


PHP get_the_content函数代码示例

本文整理汇总了PHP中get_the_content函数的典型用法代码示例。如果您正苦于以下问题:PHP get_the_content函数的具体用法?PHP get_the_content怎么用?PHP get_the_content使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_the_content函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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(']]>', ']]&gt;', $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(']]>', ']]&gt;', $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(']]>', ']]&gt;', $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">&rarr; </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(']]>', ']]&gt;', $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 &rarr;</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(']]>', ']]&gt;', $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(']]>', ']]&gt;', $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(']]>', ']]&gt;', $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(']]>', ']]&gt;', $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


注:本文中的get_the_content函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。