本文整理汇总了PHP中the_author_posts_link函数的典型用法代码示例。如果您正苦于以下问题:PHP the_author_posts_link函数的具体用法?PHP the_author_posts_link怎么用?PHP the_author_posts_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了the_author_posts_link函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: mb_entry_date_auth
function mb_entry_date_auth()
{
ob_start();
the_author_posts_link();
echo '<div class="entry-date-auth">
<time class="updated" datetime="' . get_the_time('c') . '">' . sprintf(__('%s', 'mb'), get_the_date()) . '</time>' . __(' By ', 'responsive-brix') . ob_get_clean() . '</div>';
}
开发者ID:hect1c,项目名称:martina-blog,代码行数:7,代码来源:entry-meta.php
示例2: _post
echo "</div>";
}
function _post()
{
?>
<!-- POSTS -->
<div class="post">
<div class="posthead">
<span class="date">
<?php
the_time('d/m/Y');
?>
</span><!-- /date -->
<span class="autor">
<?php
the_author_posts_link();
?>
</span>
<?php
//the_category(" | ")
?>
</div><!-- /headpost -->
<div class="postcontent">
<h1><a href="<?php
the_permalink();
?>
" title="<?php
the_title();
开发者ID:ruanltbg,项目名称:jQuery-Brasil,代码行数:29,代码来源:functions.php
示例3: mh_post_meta
function mh_post_meta()
{
global $options;
$post_date = isset($options['post_meta_date']) ? !$options['post_meta_date'] : true;
$post_author = isset($options['post_meta_author']) ? !$options['post_meta_author'] : true;
$post_cat = isset($options['post_meta_cat']) ? !$options['post_meta_cat'] : true;
$post_comments = isset($options['post_meta_comments']) ? !$options['post_meta_comments'] : true;
if ($post_date || $post_author || $post_cat || $post_comments) {
echo '<p class="meta post-meta">';
if ($post_date || $post_author || $post_cat) {
echo __('Posted ', 'mh');
}
if ($post_date) {
echo __('on ', 'mh') . '<span class="updated">' . get_the_date() . '</span>';
}
if ($post_author) {
echo __(' by ', 'mh') . '<span class="vcard author"><span class="fn">';
the_author_posts_link();
echo '</span></span>';
}
if ($post_cat) {
echo __(' in ', 'mh');
the_category(', ');
}
if ($post_date && $post_comments || $post_author && $post_comments || $post_cat && $post_comments) {
echo ' // ';
}
if ($post_comments) {
comments_number(__('0 Comments', 'mh'), __('1 Comment', 'mh'), __('% Comments', 'mh'));
}
echo '</p>' . "\n";
}
}
开发者ID:davidHuanghw,项目名称:david_blog,代码行数:33,代码来源:mh-content.php
示例4: blog_thumbnail_style
function blog_thumbnail_style($atts, $current)
{
global $post, $mk_options;
extract($atts);
$image_height = $grid_image_height;
if ($thumbnail_align == 'left') {
$align_class = ' content-align-right';
} else {
$align_class = ' content-align-left';
}
if ($layout == 'full') {
$image_width = $grid_width - 40;
} else {
$image_width = $content_width / 100 * $grid_width - 40;
}
$output = $has_image = '';
$post_type = get_post_meta($post->ID, '_single_post_type', true);
/*
* Image Width : 600px
* Image Height : 460px
*/
$image_src_array = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full', true);
$image_output_src = bfi_thumb($image_src_array[0], array('width' => '600', 'height' => '460'));
if ($post_type == '') {
$post_type = 'image';
}
$output .= '<article id="' . get_the_ID() . '" class="mk-blog-thumbnail-item thumbnail-' . $item_id . ' mk-isotop-item ' . $post_type . '-post-type' . $align_class . '">' . "\n";
if (has_post_thumbnail()) {
$output .= '<div class="featured-image" ><a href="' . get_permalink() . '" title="' . get_the_title() . '">';
$output .= ' <img alt="' . get_the_title() . '" title="' . get_the_title() . '" src="' . $image_output_src . '" itemprop="image" />';
$output .= ' <div class="image-hover-overlay"></div>';
$output .= ' <div class="post-type-badge" href="' . get_permalink() . '"><i class="mk-li-' . $post_type . '"></i></div>';
$output .= '</a></div>';
}
$output .= '<div class="mk-thumbnail-content-container">';
$output .= ' <div class="mk-blog-meta">';
$output .= ' <div class="mk-blog-author">';
ob_start();
the_author_posts_link();
$output .= ob_get_contents() . '</div>';
ob_get_clean();
$output .= ' <span class="mk-categories"> / ' . __('', 'mk_framework') . ' ' . get_the_category_list(', ') . ' </span> /
<time datetime="' . get_the_date() . '">
<a href="' . get_month_link(get_the_time("Y"), get_the_time("m")) . '">' . get_the_date() . '</a>
</time>';
$output .= ' <h3 class="the-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
if ($excerpt_length != 0) {
ob_start();
the_excerpt_max_charlength($excerpt_length);
$output .= '<div class="the-excerpt"><p>' . ob_get_clean() . '</p></div>';
}
$output .= ' <div class="mk-teader-button">' . do_shortcode('[mk_button dimension="outline" corner_style="pointed" outline_skin="custom" outline_active_color="#000000" outline_hover_color="#fff" margin_bottom="0" size="medium" align="left" url="' . get_permalink() . '"]' . __('READ MORE', 'mk_framework') . '[/mk_button]') . '
</div>';
$output .= ' </div>';
$output .= ' </div>';
$output .= '<div class="clearboth"></div>';
$output .= '</article>' . "\n\n\n";
return $output;
}
开发者ID:kevalbaxi,项目名称:dosomething-blog,代码行数:59,代码来源:thumbnail.php
示例5: widget
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? 'Popular This Week' : $instance['title']);
$postsNum = empty($instance['postsNum']) ? '' : (int) $instance['postsNum'];
$show_thisweek = isset($instance['thisweek']) ? (bool) $instance['thisweek'] : false;
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
$additional_query = $show_thisweek ? '&year=' . date('Y') . '&w=' . date('W') : '';
query_posts('post_type=post&posts_per_page=' . $postsNum . '&orderby=comment_count&order=DESC' . $additional_query);
?>
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
?>
<div class="blog-entry">
<a href="<?php
the_permalink();
?>
" class="comments"><?php
comments_number('0', '1', '%');
?>
</a>
<h4 class="title"><a href="<?php
the_permalink();
?>
"><?php
the_title();
?>
</a></h4>
<p class="meta-info"><?php
esc_html_e('Posted', 'Aggregate');
?>
<?php
esc_html_e('by', 'Aggregate');
?>
<?php
the_author_posts_link();
?>
<?php
esc_html_e('on', 'Aggregate');
?>
<?php
the_time('n-j-y');
?>
</p>
</div>
<?php
}
}
wp_reset_query();
?>
<?php
echo $after_widget;
}
开发者ID:damiansu,项目名称:wordpress-es,代码行数:59,代码来源:widget-popular.php
示例6: kouki_post_meta
/**
* Post Meta
* @since 1.7.0
*/
function kouki_post_meta()
{
?>
<p class="meta">
<?php
/**
* Check for theme-options and echo the right meta-data for posts.
*/
$post_show_author = of_get_option('kouki_post_show_author');
$post_show_category = of_get_option('kouki_post_show_category');
$post_show_date = of_get_option('kouki_post_show_date');
$post_show_comments = of_get_option('kouki_post_show_comments');
if ($post_show_author || $post_show_date || $post_show_category) {
_e('Posted ', 'kouki');
}
if ($post_show_author) {
_e('by ', 'kouki');
?>
<?php
the_author_posts_link();
_e(' ', 'kouki');
}
if ($post_show_date) {
_e('on', 'kouki');
?>
<a href="<?php
the_permalink();
?>
"><?php
the_time('M j, Y ');
?>
</a> <?php
}
if ($post_show_category && get_the_category()) {
_e('in', 'kouki');
?>
<?php
the_category(', ');
}
if (($post_show_author || $post_show_date || $post_show_category) && $post_show_comments) {
echo "<br>";
}
if ($post_show_comments) {
?>
<a href="<?php
comments_link();
?>
"><?php
comments_number(__('No Comments', 'kouki'), __('One Comment', 'kouki'), __('% Comments', 'kouki'));
?>
</a>
<?php
}
?>
</p>
<?php
}
开发者ID:mmanishh,项目名称:kouki,代码行数:63,代码来源:template-tags.php
示例7: get_author
function get_author()
{
$author = get_newspapermeta('author', 0);
if (!empty($author)) {
echo $author;
} else {
the_author_posts_link();
}
}
开发者ID:Jonatan,项目名称:wp-newspapermeta,代码行数:9,代码来源:newspapermeta.php
示例8: authorWidget
function authorWidget()
{
$settings = get_option("widget_authorwidget");
$title = $settings['title'];
if ($title == "") {
$title = __('Author Info', 'woothemes');
}
if (is_single()) {
?>
<div id="author" class="widget">
<h3 class="widget_title"><img src="<?php
bloginfo('template_directory');
?>
/images/ico-author.png" alt="" /><?php
echo $title;
?>
</h3>
<div class="wrap">
<div class="fl"><?php
echo get_avatar(get_the_author_id(), '48');
?>
</div>
<span class="author-info"><?php
_e('This post was written by', 'woothemes');
?>
<?php
the_author_posts_link();
?>
<?php
_e('who has written', 'woothemes');
?>
<?php
the_author_posts();
?>
<?php
_e('posts on', 'woothemes');
?>
<a href="<?php
echo get_option('home');
?>
/"><?php
bloginfo('name');
?>
</a>.</span>
<br class="fix"></br>
<p class="author-desc"><?php
the_author_description();
?>
</p>
</div>
</div>
<?php
}
}
开发者ID:juslee,项目名称:e27,代码行数:56,代码来源:theme-widgets.php
示例9: pagelines_post_author_posts_link_shortcode
function pagelines_post_author_posts_link_shortcode($atts)
{
$defaults = array('before' => '', 'after' => '');
$atts = shortcode_atts($defaults, $atts);
// Prevent automatic WP Output
ob_start();
the_author_posts_link();
$author = ob_get_clean();
$output = sprintf('<span class="author vcard">%2$s<span class="fn">%1$s</span>%3$s</span>', $author, $atts['before'], $atts['after']);
return apply_filters('pagelines_post_author_shortcode', $output, $atts);
}
开发者ID:TheTypoMaster,项目名称:akpsibruins,代码行数:11,代码来源:library.shortcodes.php
示例10: ktz_author_box
function ktz_author_box()
{
if (ot_get_option('ktz_active_autbox') == 'yes') {
if (is_single()) {
echo '<div class="ktz-authorbox"><div class="panel panel-default">';
echo '<div class="panel-heading clearfix">';
echo '<div class="pull-left">' . __('Author:', ktz_theme_textdomain) . ' ';
echo the_author_posts_link();
echo '</div>';
echo '<ul class="ktz-socialicon pull-right">';
if (get_the_author_meta('twitter') != '' || get_the_author_meta('facebook') != '' || get_the_author_meta('googleplus') != '' || get_the_author_meta('url') != '') {
if (get_the_author_meta('twitter') != '') {
echo '<li class="twitter"><a target="_blank" href="http://twitter.com/';
echo the_author_meta('twitter');
echo '" title="' . __('Follow', ktz_theme_textdomain) . ' ';
echo the_author_meta('display_name');
echo ' ' . __('on Twitter', ktz_theme_textdomain) . '"><span class="fontawesome ktzfo-twitter"></span></a></li>';
}
if (get_the_author_meta('facebook') != '') {
echo '<li class="facebook"><a target="_blank" href="';
echo the_author_meta('facebook');
echo '" title="' . __('Add', ktz_theme_textdomain) . ' ';
echo the_author_meta('display_name');
echo ' ' . __('on facebook', ktz_theme_textdomain) . '"><span class="fontawesome ktzfo-facebook"></span></a></li>';
}
if (get_the_author_meta('googleplus') != '') {
echo '<li class="gplus"><a target="_blank" href="';
echo the_author_meta('googleplus');
echo '" title="' . __('Cycle', ktz_theme_textdomain) . ' ';
echo the_author_meta('display_name');
echo ' ' . __('on googleplus', ktz_theme_textdomain) . '"><span class="fontawesome ktzfo-google-plus"></span></a></li>';
}
if (get_the_author_meta('url') != '') {
echo '<li class="rss"><a target="_blank" href="';
echo the_author_meta('url');
echo '" title="';
echo the_author_meta('display_name');
echo ' ' . __('site', ktz_theme_textdomain) . '"><span class="fontawesome ktzfo-rss"></span></a></li>';
}
}
echo '</ul>';
echo '</div>';
echo '<div class="panel-body clearfix">';
echo '<div class="ktz-author-thumb pull-left">';
echo get_avatar(get_the_author_meta('user_email'), $size = '52', '', $alt = 'author');
echo '</div>';
echo '<div class="ktz-author-desc">';
echo the_author_meta('description');
echo '</div>';
echo '</div>';
echo '</div></div>';
}
}
}
开发者ID:jjpango,项目名称:JJTeam,代码行数:54,代码来源:_authorbox_ktz.php
示例11: sa_add_author_info
function sa_add_author_info($content)
{
ob_start();
the_author_posts_link();
$author_post_link = ob_get_contents();
ob_end_clean();
if (get_option('sa_add_to_content') == 'yes') {
return $content . '</br><p>Author: ' . $author_post_link . '</p>';
}
return $content;
}
开发者ID:ranveerkunal,项目名称:showauthor,代码行数:11,代码来源:showauthor.php
示例12: genesis_post_author_posts_link_shortcode
function genesis_post_author_posts_link_shortcode($atts)
{
$defaults = array('before' => '', 'after' => '');
$atts = shortcode_atts($defaults, $atts);
// Darn you, WordPress!
ob_start();
the_author_posts_link();
$author = ob_get_clean();
$output = sprintf('<span class="author vcard">%2$s<span class="fn">%1$s</span>%3$s</span>', $author, $atts['before'], $atts['after']);
return apply_filters('genesis_post_author_shortcode', $output, $atts);
}
开发者ID:Weissenberger13,项目名称:web.portugalrentalcottages,代码行数:11,代码来源:post.php
示例13: widget
function widget($args, $instance)
{
extract($args);
$instance = wp_parse_args((array) $instance, array('title' => '', 'posts_cat' => '', 'posts_num' => '', 'posts_offset' => '', 'orderby' => '', 'order' => '', 'show_image' => 0, 'image_alignment' => '', 'image_size' => '', 'show_title' => 0, 'show_byline' => 0, 'show_content' => 0, 'content_limit' => '', 'more_text' => ''));
echo $before_widget;
$featured_posts = new WP_Query(array('cat' => $instance['posts_cat'], 'showposts' => $instance['posts_num'], 'offset' => $instance['posts_offset'], 'orderby' => $instance['orderby'], 'order' => $instance['order']));
if ($featured_posts->have_posts()) {
while ($featured_posts->have_posts()) {
$featured_posts->the_post();
echo '<li ';
post_class('feature-post');
echo '>';
if (!empty($instance['show_image'])) {
echo '<a href="' . get_permalink() . '" title="' . get_the_title() . '" class="' . esc_attr($instance['image_alignment']) . ' feature-image">';
genesis_image(array('format' => 'html', 'size' => $instance['image_size']));
echo '</a>';
}
if (!empty($instance['show_title'])) {
echo '<h2 class="title"><a href="' . get_permalink() . '" title="' . esc_attr(get_the_title()) . '">' . get_the_title() . '</a></h2>';
}
if (!empty($instance['show_byline'])) {
echo '<p class="byline">';
the_time('F j, Y');
echo ' ' . __('by', 'genesis') . ' ';
the_author_posts_link();
echo ' · ';
comments_popup_link(__('Leave a Comment', 'genesis'), __('1 Comment', 'genesis'), __('% Comments', 'genesis'));
echo ' ';
edit_post_link(__('(Edit)', 'genesis'), '', '');
echo '</p>';
}
if (!empty($instance['show_content'])) {
if ($instance['show_content'] == 'excerpt') {
the_excerpt();
} elseif ($instance['show_content'] == 'content-limit') {
the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
} else {
the_content(esc_html($instance['more_text']));
}
}
echo '</li><!--end post_class()-->' . "\n\n";
if (!empty($instance['show_slider_nav'])) {
$slider_nav .= '<li><a href="#"></a></li>';
}
}
}
echo $after_widget;
echo '<div class="feature-nav ' . esc_attr($instance['image_alignment']) . '">';
echo '<ul>';
echo $slider_nav;
echo '</ul></div>';
wp_reset_query();
}
开发者ID:nmrugg,项目名称:studiopress-premum-wp-themes,代码行数:53,代码来源:lexicon-slider-widget.php
示例14: widget
function widget($args, $instance)
{
extract($args);
if (!is_single()) {
return;
}
$title = apply_filters('widget_title', $instance['title']);
if (empty($title)) {
$title = false;
}
$show_gravatar = $instance['show_gravatar'] == 1 ? true : false;
$show_bio = $instance['show_bio'] == 1 ? true : false;
echo $before_widget;
if ($title) {
echo $before_title;
echo $title;
echo $after_title;
}
?>
<div class="author-info cf">
<?php
if ($show_gravatar) {
echo get_avatar(get_the_author_meta('email'), '60');
}
?>
<span><?php
echo stripslashes(get_option('dt_lang_gen_postedby'));
?>
<?php
the_author_posts_link();
?>
</span>
<?php
if ($show_bio) {
?>
<p><?php
the_author_meta('description');
?>
</p>
<?php
}
?>
</div><!-- .author-info -->
<?php
echo $after_widget;
}
开发者ID:jainankit,项目名称:suggstme,代码行数:51,代码来源:widget-authorinfo.php
示例15: mh_post_meta
function mh_post_meta()
{
global $options;
if (isset($options['post_meta']) ? !$options['post_meta'] : true) {
echo '<p class="meta post-meta">' . __('Posted on ', 'mh') . '<span class="updated">' . get_the_date() . '</span>' . __(' by ', 'mh');
echo '<span class="vcard author"><span class="fn">';
the_author_posts_link();
echo '</span></span>' . __(' in ', 'mh');
the_category(', ');
echo ' // ';
comments_number(__('0 Comments', 'mh'), __('1 Comment', 'mh'), __('% Comments', 'mh'));
echo '</p>' . "\n";
}
}
开发者ID:Gabriel-07,项目名称:site,代码行数:14,代码来源:mh-content.php
示例16: usp_author_link
function usp_author_link()
{
global $post, $usp_post_meta_IsSubmission, $usp_post_meta_Submitter, $usp_post_meta_SubmitterUrl;
$isSubmission = get_post_meta($post->ID, $usp_post_meta_IsSubmission, true);
$submissionAuthor = get_post_meta($post->ID, $usp_post_meta_Submitter, true);
$submissionLink = get_post_meta($post->ID, $usp_post_meta_SubmitterUrl, true);
if ($isSubmission && !empty($submissionAuthor)) {
if (empty($submissionLink)) {
echo '<span class="usp-author-link">' . $submissionAuthor . '</span>';
} else {
echo '<span class="usp-author-link"><a href="' . $submissionLink . '">' . $submissionAuthor . '</a></span>';
}
} else {
the_author_posts_link();
}
}
开发者ID:juslee,项目名称:e27,代码行数:16,代码来源:template-tags.php
示例17: widget_sideFeature
function widget_sideFeature()
{
$options = get_option("widget_sideFeature");
$numberOf = $options['number'];
$category = $options['category'];
$category = "&cat=" . $category;
$showposts = "posts_per_page=" . $numberOf . $category;
?>
<?php
$featuredPosts = new WP_Query();
$featuredPosts->query($showposts);
?>
<?php
$i = 1;
?>
<?php
while ($featuredPosts->have_posts()) {
$featuredPosts->the_post();
?>
<h3 class="side"><a href="<?php
the_permalink();
?>
"><?php
the_title();
?>
</a></h3>
<div class="meta">
<?php
_e("By", "feed-me-seymour");
echo " ";
the_author_posts_link();
?>
</div>
<div class="storycontent <?php
if ($numberOf == $i) {
echo "noline";
}
$i++;
?>
">
<?php
theme_excerpt('25');
?>
</div>
<?php
}
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:47,代码来源:widget_feature.php
示例18: widget
function widget($args, $instance)
{
extract($args);
$instance = wp_parse_args((array) $instance, array('title' => '', 'page_id' => '', 'show_image' => 0, 'image_alignment' => '', 'image_size' => '', 'show_title' => 0, 'show_byline' => 0, 'show_content' => 0, 'content_limit' => '', 'more_text' => ''));
echo $before_widget;
// Set up the author bio
if (!empty($instance['title'])) {
echo $before_title . apply_filters('widget_title', $instance['title']) . $after_title;
}
$featured_page = new WP_Query(array('page_id' => $instance['page_id']));
if ($featured_page->have_posts()) {
while ($featured_page->have_posts()) {
$featured_page->the_post();
echo '<div ';
post_class();
echo '>';
if (!empty($instance['show_image'])) {
printf('<a href="%s" title="%s" class="%s">%s</a>', get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'])));
}
if (!empty($instance['show_title'])) {
printf('<h2><a href="%s" title="%s">%s</a></h2>', get_permalink(), the_title_attribute('echo=0'), the_title_attribute('echo=0'));
}
if (!empty($instance['show_byline'])) {
echo '<p class="byline">';
the_time('F j, Y');
echo ' ' . __('by', 'genesis') . ' ';
the_author_posts_link();
echo g_ent(' · ');
comments_popup_link(__('Leave a Comment', 'genesis'), __('1 Comment', 'genesis'), __('% Comments', 'genesis'));
echo ' ';
edit_post_link(__('(Edit)', 'genesis'), '', '');
echo '</p>';
}
if (!empty($instance['show_content'])) {
if (empty($instance['content_limit'])) {
the_content($instance['more_text']);
} else {
the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
}
}
echo '</div><!--end post_class()-->' . "\n\n";
}
}
echo $after_widget;
wp_reset_query();
}
开发者ID:Weissenberger13,项目名称:web.portugalrentalcottages,代码行数:46,代码来源:featured-page-widget.php
示例19: hoot_get_post_author
/**
* Function for getting the current post's author in The Loop and linking to the author archive page.
* This function was created because core WordPress does not have template tags with proper translation
* and RTL support for this. An equivalent getter function for `the_author_posts_link()` would
* instantly solve this issue.
*
* @since 1.0.0
* @access public
* @param array $args
* @return string
*/
function hoot_get_post_author($args = array())
{
$html = '';
$defaults = array('text' => '%s', 'before' => '', 'after' => '', 'wrap' => '<span %s>%s</span>');
$args = wp_parse_args($args, $defaults);
/* Output buffering to get the author posts link. */
ob_start();
the_author_posts_link();
$link = ob_get_clean();
/* A small piece of my soul just died. Kittens no longer purr. Dolphins lost the ability to swim with grace. */
if (!empty($link)) {
$html .= $args['before'];
$html .= sprintf($args['wrap'], hoot_get_attr('entry-author'), sprintf($args['text'], $link));
$html .= $args['after'];
}
return $html;
}
开发者ID:acafourek,项目名称:maidstone,代码行数:28,代码来源:template-post.php
示例20: dwqa_related_question
/**
* Get related questions [description]
*/
function dwqa_related_question($question_id = false, $number = 5, $echo = true)
{
if (!$question_id) {
$question_id = get_the_ID();
}
$tag_in = $cat_in = array();
$tags = wp_get_post_terms($question_id, 'dwqa-question_tag');
if (!empty($tags)) {
foreach ($tags as $tag) {
$tag_in[] = $tag->term_id;
}
}
$category = wp_get_post_terms($question_id, 'dwqa-question_category');
if (!empty($category)) {
foreach ($category as $cat) {
$cat_in[] = $cat->term_id;
}
}
$args = array('orderby' => 'rand', 'post__not_in' => array($question_id), 'showposts' => $number, 'ignore_sticky_posts' => 1, 'post_type' => 'dwqa-question');
$args['tax_query']['relation'] = 'OR';
if (!empty($cat_in)) {
$args['tax_query'][] = array('taxonomy' => 'dwqa-question_category', 'field' => 'id', 'terms' => $cat_in, 'operator' => 'IN');
}
if (!empty($tag_in)) {
$args['tax_query'][] = array('taxonomy' => 'dwqa-question_tag', 'field' => 'id', 'terms' => $tag_in, 'operator' => 'IN');
}
$related_questions = new WP_Query($args);
if ($related_questions->have_posts()) {
if ($echo) {
echo '<ul>';
while ($related_questions->have_posts()) {
$related_questions->the_post();
echo '<li><a href="' . get_permalink() . '" class="question-title">' . get_the_title() . '</a> ' . __('asked by', 'dwqa') . ' ';
the_author_posts_link();
echo '</li>';
}
echo '</ul>';
}
}
$posts = $related_questions->posts;
wp_reset_postdata();
return $posts;
}
开发者ID:layoutzweb,项目名称:dw-question-answer,代码行数:46,代码来源:Question.php
注:本文中的the_author_posts_link函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论