本文整理汇总了PHP中excerpt函数的典型用法代码示例。如果您正苦于以下问题:PHP excerpt函数的具体用法?PHP excerpt怎么用?PHP excerpt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了excerpt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: categoryContent
function categoryContent($cat, $post_count)
{
query_posts("posts_per_page={$post_count}&cat={$cat}&orderby=ID");
?>
<ul>
<?php
while (have_posts()) {
the_post();
?>
<li><a href='<?php
the_permalink();
?>
'><?php
the_title();
?>
</a><br>
<p><?php
excerpt(20);
?>
</p>
</li>
<?php
}
?>
</ul>
<?php
}
示例2: save
public function save(PostRequest $request, $forum, $topic, $post = null)
{
$url = \DB::transaction(function () use($request, $forum, $topic, $post) {
// parsing text and store it in cache
$text = app()->make('Parser\\Post')->parse($request->text);
// post has been modified...
if ($post !== null) {
$this->authorize('update', [$post, $forum]);
$data = $request->only(['text', 'user_name']) + ['edit_count' => $post->edit_count + 1, 'editor_id' => auth()->id()];
$post->fill($data)->save();
$activity = Stream_Update::class;
// user want to change the subject. we must update topics table
if ($post->id === $topic->first_post_id) {
$path = str_slug($request->get('subject'), '_');
$topic->fill($request->all() + ['path' => $path])->save();
$this->topic->setTags($topic->id, $request->get('tag', []));
}
} else {
$activity = Stream_Create::class;
// create new post and assign it to topic. don't worry about the rest: trigger will do the work
$post = $this->post->create($request->all() + ['user_id' => auth()->id(), 'topic_id' => $topic->id, 'forum_id' => $forum->id, 'ip' => request()->ip(), 'browser' => request()->browser(), 'host' => request()->server('SERVER_NAME')]);
// get id of users that were mentioned in the text
$usersId = (new Ref_Login())->grab($text);
if ($usersId) {
app()->make('Alert\\Post\\Login')->with(['users_id' => $usersId, 'sender_id' => auth()->id(), 'sender_name' => $request->get('user_name', auth()->user()->name), 'subject' => excerpt($topic->subject, 48), 'excerpt' => excerpt($text), 'url' => route('forum.topic', [$forum->path, $topic->id, $topic->path], false)])->notify();
}
}
$url = route('forum.topic', [$forum->path, $topic->id, $topic->path], false);
$url .= '?p=' . $post->id . '#id' . $post->id;
$object = (new Stream_Post(['url' => $url]))->map($post);
stream($activity, $object, (new Stream_Topic())->map($topic, $forum));
return $url;
});
return redirect()->to($url);
}
示例3: doFeed
function doFeed($feed)
{
$rss = new DOMDocument();
if ($rss->load($feed)) {
$feed = array();
foreach ($rss->getElementsByTagName('item') as $node) {
$item = array('title' => $node->getElementsByTagName('title')->item(0)->nodeValue, 'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue, 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue);
array_push($feed, $item);
}
$limit = 3;
for ($x = 0; $x < $limit; $x++) {
$title = str_replace(' & ', ' & ', $feed[$x]['title']);
$link = $feed[$x]['link'];
$description = $feed[$x]['desc'];
$date = date('l, F d, Y', strtotime($feed[$x]['date']));
echo '
<article>
<hgroup>
<h1><a href="' . $link . '" title="' . $title . '">' . $title . '</a>
<h2>' . $date . '</h2>
</hgroup>
<p>' . excerpt($description) . '</p>
</article>' . "\r\n";
}
} else {
echo '<p class="none">No posts found!</p>' . "\r\n";
}
}
示例4: map
public function map(Model $microblog)
{
$this->id = $microblog->id;
$this->url = route('microblog.view', [$microblog->id], false);
$this->displayName = excerpt($microblog->text);
return $this;
}
示例5: map
/**
* @param Model $microblog
* @return $this
*/
public function map(Model $microblog)
{
$this->setMicroblogId($microblog->id);
$this->setUrl(route('microblog.view', [$microblog->id], false));
$this->setUserId($microblog->user_id);
$this->setExcerpt(excerpt($microblog->text));
return $this;
}
示例6: save
public function save(Request $request)
{
$this->validate($request, ['url' => 'required|string', 'metadata' => 'json', 'type_id' => 'integer|exists:flag_types,id', 'text' => 'string']);
\DB::transaction(function () use($request) {
$flag = Flag::create($request->all() + ['user_id' => auth()->id()]);
$object = new Stream_Flag(['id' => $flag->id, 'displayName' => excerpt($request->text)]);
stream(Stream_Create::class, $object);
});
}
示例7: get_slide_items
function get_slide_items($slide_cat, $count)
{
global $post;
$args = array('posts_per_page' => $count, 'cat' => $slide_cat);
$loop = new WP_Query($args);
echo "<ul class='slides'>";
while ($loop->have_posts()) {
$loop->the_post();
?>
<li>
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];
// $thumb = get_post_thumbnail_id();
// $img_url = wp_get_attachment_url( $thumb,'full' ); //get full URL to image (use "large" or "medium" if the images too big)
// $image = aq_resize( $img_url, 960, 410, true,true,true ); //resize & crop the image
?>
<?php
if ($thumb_url) {
?>
<a href="<?php
the_permalink();
?>
"> <img src="<?php
echo $thumb_url;
?>
" alt="<?php
the_title();
?>
" /> </a>
<?php
}
?>
<div class="flex-caption">
<h2><a href="<?php
the_permalink();
?>
"> <?php
the_title();
?>
</a></h2>
<span> <?php
echo excerpt(25);
?>
</span>
</div>
</li>
<?php
}
echo "</ul>";
wp_reset_postdata();
}
示例8: map
/**
* @param Model $topic
* @param Forum $forum
* @param string|null $text
* @return $this
*/
public function map(Model $topic, Forum $forum, $text = null)
{
$this->id = $topic->id;
$this->url = route('forum.topic', [$forum->path, $topic->id, $topic->path], false);
$this->displayName = $topic->subject;
$this->forum = ['name' => $forum->name, 'id' => $forum->id, 'path' => $forum->path];
if ($text) {
$this->excerpt = excerpt($text);
}
return $this;
}
示例9: index
/**
* @param $id
* @param Microblog $repository
* @return $this
*/
public function index($id, Microblog $repository)
{
$microblog = $repository->findOrFail($id);
$excerpt = excerpt($microblog->text);
$this->breadcrumb->push('Mikroblog', route('microblog.home'));
$this->breadcrumb->push($excerpt, route('microblog.view', [$microblog->id]));
$microblog->text = app()->make('Parser\\Microblog')->parse($microblog->text);
$parser = app()->make('Parser\\Comment');
foreach ($microblog->comments as &$comment) {
$comment->text = $parser->parse($comment->text);
}
return parent::view('microblog.view')->with(['microblog' => $microblog, 'excerpt' => $excerpt]);
}
示例10: custom_excerpt
function custom_excerpt($length = '', $more_txt = 'Read More')
{
$default_length = 30;
if (empty($length)) {
$excerpt_length = $default_length;
} else {
$excerpt_length = $length;
}
$excerpt = excerpt($excerpt_length);
$link = '<a href="' . get_permalink($post->ID) . '" class="more_link">' . $more_txt . '</a>';
$output = "{$excerpt} {$link}";
echo wpautop($output, true);
}
示例11: bytbil_show_news_feed
function bytbil_show_news_feed($posts, $categories = "")
{
// set up or arguments for our custom query
if ($posts == 0) {
$posts = 10;
}
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
if ($categories != '' && count($categories) != 0) {
$query_args = array('tax_query' => array(array('taxonomy' => 'news_categories', 'field' => 'id', 'terms' => $categories)), 'posts_per_page' => $posts, 'paged' => $paged);
} else {
$query_args = array('post_type' => 'news', 'posts_per_page' => $posts, 'paged' => $paged);
}
// create a new instance of WP_Query
$the_query = new WP_Query($query_args);
?>
<?php
if ($the_query->have_posts()) {
while ($the_query->have_posts()) {
$the_query->the_post();
// run the loop
?>
<article class="news-post">
<a href="<?php
the_permalink();
?>
">
<h2><?php
echo the_title();
?>
</h2>
<div class="excerpt">
<?php
echo excerpt(45);
?>
</div>
<span class="date">Skrivet den: <?php
echo get_the_date('Y-m-d');
?>
</span>
</a>
</article>
<?php
}
}
wp_reset_query();
}
示例12: portfolio_custom_columns
function portfolio_custom_columns($column)
{
global $post;
switch ($column) {
case "portfolio_desc":
echo excerpt('25');
break;
case "portfolio_category":
echo get_the_term_list($post->ID, 'portfolio_category', '', ', ', '');
break;
case "portfolio_image":
$custom = get_post_custom();
the_post_thumbnail('thumb-admin');
break;
}
}
示例13: the_title
"><?php
the_title();
?>
</a></h3>
<em class="data-time"><?php
the_author_posts_link();
?>
<span><?php
the_time('j M');
?>
</span>, <?php
the_time('Y');
?>
</em>
<p><?php
echo excerpt(75);
?>
</p>
<a class="btn btn-primary" href="<?php
the_permalink();
?>
">Просмотреть</a>
</div>
</div>
</li>
<?php
}
?>
</ul>
示例14: while
while (have_posts()) {
the_post();
?>
<!-- blog entry -->
<article class="search-block">
<h5><a href="<?php
the_permalink();
?>
"><?php
the_title();
?>
</a></h5>
<?php
echo excerpt('26');
?>
<div class="search-permalink"><a href="<?php
the_permalink();
?>
"><?php
the_permalink();
?>
</a></div>
<hr class="gw-divider clearboth" />
</article>
<?php
示例15: rwmb_meta
?>
<?php
}
?>
<?php
$bpxl_status_excerpt_home = rwmb_meta('bpxl_status_excerpt_home', $args = array('type' => 'checkbox'), $post->ID);
if (empty($bpxl_status_excerpt_home)) {
?>
<div class="post-inner">
<div class="post-content">
<?php
$excerpt_length = $bpxl_goblog_options['bpxl_excerpt_length'];
if ($bpxl_goblog_options['bpxl_home_content'] == '2') {
the_content(__('Read More', 'bloompixel'));
} else {
echo excerpt($excerpt_length);
?>
<div class="read-more">
<a href="<?php
the_permalink();
?>
" title="<?php
the_title_attribute();
?>
" rel="bookmark"><?php
_e('Read More', 'bloompixel');
?>
</a>
</div>
<?php
}