• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_get_recent_posts函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了wp_get_recent_posts函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: custom_dashboard_display_stats

    function custom_dashboard_display_stats($widget)
    {
        ?>
				
				<p>Les principales valeurs statistiques de l'intégration BF QUOTES</p>
				<div class="inside">
					
						<?php 
        // global $wpdb;
        /*
        === JUST AS REMINDER
        post_type => product_for_sale
        taxonomy => product_for_sale_genre 
        taxonomy => product_for_sale_author 
        taxonomy => product_for_sale_kw 
        */
        $num_posts_bf_quotes_manager = wp_count_posts('bf_quotes_manager');
        // Main figures for product_for_sale
        $num_product_for_sale = $num_posts_product_for_sale->publish;
        // nb for Author(s)
        $num_cats_bf_quotes_manager_author = wp_count_terms('bf_quotes_manager_author');
        // nb for Flavor(s)
        $num_tags_bf_quotes_manager_flavor = wp_count_terms('bf_quotes_manager_flavor');
        ?>
				<h4><strong>Les chiffres-clés</strong></h4>
				<ul>
					<li>Nombre d' Auteur(s) : <b><?php 
        echo '' . $num_cats_bf_quotes_manager_author . '';
        ?>
</b></li>
					<li>Nombre de Saveur(s) : <b><?php 
        echo '' . $num_tags_bf_quotes_manager_flavor . '';
        ?>
</b></li>
					</ul>
				
				
				
				<h4><strong>Les dernières citations enregistrées</strong></h4>
			
				<?php 
        /* LAST POSTS */
        $args = array('offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'numberposts' => '3', 'post_status' => 'publish', 'post_type' => 'bf_quotes_manager');
        $recent_posts = wp_get_recent_posts($args);
        /* debug only */
        // print_r($recent_posts);
        foreach ($recent_posts as $recent) {
            setup_postdata(get_post($recent['ID']));
            // Output
            echo '<ul><li><a class="rsswidget" href="' . get_permalink($recent['ID']) . '" title="' . esc_attr(get_the_title($recent['ID'])) . '">' . get_the_title($recent['ID']) . '</a> <span class="rss-date">' . get_the_time('j F Y', $recent['ID']) . '</span><div class="rssSummary">' . $recent['post_excerpt'] . '</div></li>';
        }
        // EOL
        wp_reset_postdata();
        ?>
				
				
				</div>
					
				  <?php 
    }
开发者ID:bflaven,项目名称:PluginWordpressForFun,代码行数:60,代码来源:bf_quotes_manager_admin.php


示例2: widget

 /**
  * How to display the widget on the screen.
  */
 function widget($args, $instance)
 {
     extract($args);
     global $wp_query, $post;
     /* Our variables from the widget settings. */
     $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '');
     $post_type = isset($instance['post_type']) ? $instance['post_type'] : 'post';
     $taxonomy = axiom_get_taxonomy_categories_by_post_type($post_type);
     $number = isset($instance['number']) ? (int) $instance['number'] : '';
     $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0;
     $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0;
     $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0;
     $show_counters = isset($instance['show_counters']) && $instance['show_counters'] > 0 ? axiom_get_theme_option('blog_counters') : '';
     $category = isset($instance['category']) ? (int) $instance['category'] : 0;
     $output = '';
     $args = array('numberposts' => $number, 'offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => $post_type, 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'ignore_sticky_posts' => 1, 'suppress_filters' => true);
     if ($category > 0) {
         if ($taxonomy == 'category') {
             $args['category'] = $category;
         } else {
             $args['tax_query'] = array(array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $category));
         }
     }
     $ex = axiom_get_theme_option('exclude_cats');
     if (!empty($ex)) {
         $args['category__not_in'] = explode(',', $ex);
     }
     $recent_posts = wp_get_recent_posts($args, OBJECT);
     $post_number = 0;
     foreach ($recent_posts as $post) {
         $post_number++;
         require axiom_get_file_dir('templates/parts/widgets-posts.php');
         if ($post_number >= $number) {
             break;
         }
     }
     if (!empty($output)) {
         /* Before widget (defined by themes). */
         echo $before_widget;
         /* Display the widget title if one was input (before and after defined by themes). */
         echo $before_title . $title . $after_title;
         echo $output;
         /* After widget (defined by themes). */
         echo $after_widget;
     }
 }
开发者ID:pcuervo,项目名称:odc,代码行数:49,代码来源:recent_posts.php


示例3: Grafik_Shortcode_RecentPosts_Callback

function Grafik_Shortcode_RecentPosts_Callback($atts, $content = null)
{
    // Query Params...
    $a = shortcode_atts(array('numberposts' => 10, 'offset' => 0, 'category' => '', 'orderby' => 'post_date', 'order' => 'DESC', 'include' => null, 'exclude' => null, 'meta_key' => null, 'meta_value' => null, 'post_type' => 'post', 'post_status' => 'publish', 'suppress_filters' => true, 'heading' => 'Recent Posts', 'show_preview' => 'true', 'show_postdate' => 'true', 'show_title' => 'true', 'show_excerpt' => 'true', 'class' => '', 'id' => ''), $atts, "RecentPost");
    // Convert Category Slugs to IDs...
    $category_list = explode(",", $a['category']);
    foreach ($category_list as $key => $val) {
        if (is_numeric($val)) {
            continue;
        }
        $is_negative = substr($val, 0, 1) == "-";
        $trim_val = trim($val, "-");
        $category = get_category_by_slug($trim_val);
        $category_list[$key] = ($is_negative ? "-" : null) . $category->term_id;
    }
    $a['category'] = implode(",", $category_list);
    // Filters...
    $grafik_filters = get_option("grafik-filters");
    if (!is_array($grafik_filters)) {
        $grafik_filters = json_decode($grafik_filters, true);
    }
    // Query Recent Posts Using Params...
    $RecentPosts = wp_get_recent_posts($a, ARRAY_A);
    foreach ($RecentPosts as $RecentPost) {
        // Get Category Info...
        $info_categories = array();
        $GRAFIK_CATEGORIES = wp_get_post_categories($RecentPost['ID']);
        foreach ($GRAFIK_CATEGORIES as $key => $val) {
            $cat = get_category($val);
            // Filter Uncategorized from display...
            if (is_array($grafik_filters['category-masking']) && in_array($cat->term_id, $grafik_filters['category-masking'])) {
                continue;
            }
            $info_categories[] = '<span class="theme-recentposts-postcategory ' . $cat->slug . '">' . $cat->name . '</span>';
        }
        // Get Stored Meta Values...
        $PREFILL = array('grafik-meta-preview-desktop' => stripslashes(esc_textarea(base64_decode(get_post_meta($RecentPost['ID'], 'grafik-meta-preview-desktop', true)))), 'grafik-meta-preview-tablet' => stripslashes(esc_textarea(base64_decode(get_post_meta($RecentPost['ID'], 'grafik-meta-preview-tablet', true)))), 'grafik-meta-preview-phone' => stripslashes(esc_textarea(base64_decode(get_post_meta($RecentPost['ID'], 'grafik-meta-preview-phone', true)))), 'grafik-meta-excerpt' => apply_filters('the_excerpt', get_post_field('post_excerpt', $RecentPost['ID'])));
        // Construct Recent Post Anchor...
        $content .= '<a href="' . get_permalink($RecentPost['ID']) . '" class="theme-recentposts-post">' . ($a['show_preview'] == 'false' ? null : '<span class="theme-recentposts-postimage">' . (empty($PREFILL['grafik-meta-preview-desktop']) ? null : '<img src="' . $PREFILL['grafik-meta-preview-desktop'] . '" width="100%" height="100%" alt="' . $RecentPost['post_title'] . '" class="theme-recentposts-preview-desktop" />') . (empty($PREFILL['grafik-meta-preview-tablet']) ? null : '<img src="' . $PREFILL['grafik-meta-preview-tablet'] . '" width="100%" height="100%" alt="' . $RecentPost['post_title'] . '" class="theme-recentposts-preview-tablet" />') . (empty($PREFILL['grafik-meta-preview-phone']) ? null : '<img src="' . $PREFILL['grafik-meta-preview-phone'] . '" width="100%" height="100%" alt="' . $RecentPost['post_title'] . '" class="theme-recentposts-preview-phone" />') . '</span>') . ($a['show_postdate'] == 'false' ? null : '<span class="theme-recentposts-postdate">' . date('m/d/Y', strtotime($RecentPost['post_date'])) . '</span>') . ($a['show_title'] == 'false' ? null : '<span class="theme-recentposts-posttitle">' . $RecentPost['post_title'] . '</span>') . ($a['show_categories'] == 'false' || empty($info_categories) ? null : '<span class="theme-recentposts-postcategories">' . implode('', $info_categories) . '</span>') . ($a['show_excerpt'] == 'false' ? null : '<span class="theme-recentposts-postexcerpt">' . $PREFILL['grafik-meta-excerpt'] . '</span>') . '</a>';
    }
    // Return Content...
    return '<div class="theme-recentposts' . (empty($a['class']) ? null : ' ' . $a['class']) . '"' . (empty($a['id']) ? null : ' id="' . $a['id'] . '"') . '>' . '<div class="theme-recentposts-interior">' . (empty($a['heading']) ? null : '<h2>' . $a['heading'] . '</h2>') . (empty($content) ? null : $content) . '</div>' . '</div>';
}
开发者ID:GrafikMatthew,项目名称:Grafik-Engine-Alpha,代码行数:43,代码来源:RecentPosts.php


示例4: widget

    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $Num = apply_filters('$Num', $instance['Num']);
        if (!empty($instance['title'])) {
            //TEMISI BOSH QALDURULSA  'رەڭدار خەتكۈشلەر'  BOLUP KORINIDU
            $title = $instance['title'];
        } else {
            $title = 'ئەڭ يېڭى يازمىلار';
        }
        if (!empty($instance['Num'])) {
            $Num = $instance['Num'];
        } else {
            $Num = '10';
        }
        $title = apply_filters('widget_title', $title, $instance, $this->id_base);
        $Num = apply_filters('$Num', $Num, $instance, $this->id_base);
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
<ul>
<?php 
        $args = array('numberposts' => $Num);
        $recent_posts = wp_get_recent_posts($args);
        $i = 0;
        foreach ($recent_posts as $recent) {
            if ($i % 2 == 0) {
                echo '<li class="item odd">';
            } else {
                echo '<li class="item even">';
            }
            $i++;
            echo '<a href="' . get_permalink($recent["ID"]) . '" title="' . esc_attr($recent["post_title"]) . ' نى كۆرۈش"' . '  target = "' . 'blank">' . $recent["post_title"] . '</a> </li> ';
        }
        ?>
</ul>
		<?php 
        echo $after_widget;
    }
开发者ID:MenZil-Team,项目名称:gulzar,代码行数:42,代码来源:new_posts.php


示例5: recent_posts

function recent_posts()
{
    ?>


<ul>

  <?php 
    $args = array('numberposts' => '5');
    $recent_posts = wp_get_recent_posts($args);
    foreach ($recent_posts as $recent) {
        echo '<li><a href="' . get_permalink($recent["ID"]) . '" title="Look ' . esc_attr($recent["post_title"]) . '" >' . $recent["post_title"] . '</a> </li> ';
    }
    ?>

</ul>


<?php 
}
开发者ID:pixelstorm,项目名称:nav_systems,代码行数:20,代码来源:recent_posts.php


示例6: 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;
     }
     ob_start();
     extract($args);
     $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
     $count = $instance['count'];
     $category = $instance['category'];
     $posts = wp_get_recent_posts(array('post_type' => 'post', 'numberposts' => $count, 'post_status' => 'publish', 'category' => $category), OBJECT);
     global $post;
     echo $before_widget;
     echo '<section class="recent-posts-grid" data-layout="2-2-2-2">';
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     foreach ($posts as $post) {
         setup_postdata($post);
         add_filter('stag_showing_related_posts', '__return_true');
         get_template_part('content', get_post_format());
     }
     echo '</section>';
     wp_reset_postdata();
     remove_all_filters('stag_showing_related_posts');
     echo $after_widget;
     $content = ob_get_clean();
     echo $content;
     $this->cache_widget($args, $content);
 }
开发者ID:frontend-labs,项目名称:post-template,代码行数:39,代码来源:recent-posts-grid.php


示例7: getArticlesForReview

 public static function getArticlesForReview()
 {
     $post_types = apply_filters('instant_articles_post_types', array('post'));
     // Cap the number of articles returned to
     // 100 because of performance concerns.
     return wp_get_recent_posts(array('numberposts' => min(self::MIN_ARTICLES, 100), 'post_type' => $post_types), 'OBJECT');
 }
开发者ID:ActiveWebsite,项目名称:BoojPressPlugins,代码行数:7,代码来源:class-instant-articles-wizard-review-submission.php


示例8: widget

    function widget($args, $instance)
    {
        // Widget output
        $args = array('numberposts' => 1, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_status' => 'publish', 'suppress_filters' => true);
        $recent_posts = wp_get_recent_posts($args, ARRAY_A);
        $thumb_url = wp_get_attachment_image(get_post_thumbnail_id($recent_posts[0]['ID']), array(194, 220), true);
        ?>

        <div class="blog">
            <div class="blog-image">
                <img src="<?php 
        echo get_template_directory_uri();
        ?>
/img/blog.png"/>
            </div>
            <div class="image">
                <?php 
        echo $thumb_url;
        ?>

            </div>
            <div class="content">
                <?php 
        echo $recent_posts[0]['post_excerpt'];
        ?>

                <a href="<?php 
        echo get_permalink($recent_posts[0]['ID']);
        ?>
">Read more</a>
            </div>
        </div>
        <?php 
    }
开发者ID:rongandat,项目名称:sallumeh,代码行数:34,代码来源:lastestBlog.php


示例9: widget

    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        $recent_posts = wp_get_recent_posts(array('numberposts' => 9, 'post_type' => 'wedding_registry', 'orderby' => 'post_date', 'post_status' => 'publish'));
        $i = 0;
        echo '<div class="registry-row">';
        foreach ($recent_posts as $recent) {
            $i++;
            $spouse_a = get_post_meta($recent["ID"], 'wedding_registry_field_a', true);
            $spouse_b = get_post_meta($recent["ID"], 'wedding_registry_field_b', true);
            if ($i < 9) {
                echo '
						<div class="hidden-xs hidden-sm col-md-4 col-lg-3 reg-widg center-block">
							<a href="' . get_permalink($recent['ID']) . '" title="' . $spouse_a . ' & ' . $spouse_b . '">
										<div class="lgcaption caption registry-overlay text-center" style="display:none;">
											<span class="icon-heart icom circled-icon"></span><p class="solid-text">' . $spouse_a . '<br/> & <br/>' . $spouse_b . '</p>
										</div>
										<div class="registry-widget-thumbnail center-block">' . get_the_post_thumbnail($recent['ID'], 'medium-cropped', array('class' => 'img-responsive center-block reg-thumb')) . '</div>
							</a>
							</div>';
            } else {
                echo '
						<div class="col-md-4 col-lg-3 reg-widg center-block last-reg">
										<a href="' . get_permalink($recent['ID']) . '" title="' . $spouse_a . ' & ' . $spouse_b . '">
													<div class="caption registry-overlay text-center" style="display:none;">
														<span class="icon-heart icom circled-icon"></span><p class="solid-text">' . $spouse_a . '<br/> & <br/>' . $spouse_b . '</p>
													</div>
													<div class="registry-widget-thumbnail center-block last-reg">' . get_the_post_thumbnail($recent['ID'], 'medium-cropped', array('class' => 'center-block reg-thumb')) . '</div>
										</a>
										</div>';
            }
        }
        echo '</div><div class="clearfix">&nbsp;</div>';
    }
开发者ID:ljohnso16,项目名称:amttravel,代码行数:41,代码来源:registry-widget.php


示例10: get_latest_news_stories_ps

 private function get_latest_news_stories_ps()
 {
     // Returns posts as arrays instead of get_posts' objects
     $recent_posts = wp_get_recent_posts(array('numberposts' => 4, 'category' => 10, 'post_status' => 'publish', 'meta_key' => '_thumbnail_id'));
     /*
      * Set incrementer
      */
     $i = 0;
     $news_string = '';
     foreach ($recent_posts as $post) {
         if ($i < 1) {
             $news_string .= '<a href="' . get_permalink($post['ID']) . '">
                 <div class="row">
                     <div class="columns">
                         <figure>' . get_the_post_thumbnail($post['ID'], 'thumbnail') . '</figure>
                         <p>' . $post['post_title'] . '</p>
                     </div>
                 </div>
             </a>';
         } else {
             $news_string .= '<a href = "' . get_permalink($post['ID']) . '">
                 <div class = "row">
                     <div class = "columns medium-12 large-4">
                         <figure>' . get_the_post_thumbnail($post['ID'], 'thumbnail') . '</figure>
                     </div>
                     <div class = "columns medium-12 large-8">
                         <p>' . $post['post_title'] . '</p>
                     </div>
                 </div>
             </a>';
         }
         $i++;
     }
     return $news_string;
 }
开发者ID:uthsc,项目名称:news-feeds,代码行数:35,代码来源:redesign-news-featured.php


示例11: wordlift_footer

function wordlift_footer()
{
    if ("true" !== get_option("wordlift_show_footer_bar", "true")) {
        return;
    }
    if (is_home()) {
        $args = array("numberposts" => 1, "orderby" => "post_date", "order" => "DESC", "post_type" => "post", "post_status" => "publish", "suppress_filters" => true);
        $recentPosts = wp_get_recent_posts($args, $output = ARRAY_A);
        if (0 === count($recentPosts)) {
            return;
        }
        $id = $recentPosts[0]["ID"];
    } else {
        $id = get_the_ID();
    }
    $context = WordPress_XmlApplication::getContext("wordLift");
    $postEntitiesService = $context->getClass("postEntitiesService");
    $entities = $postEntitiesService->get($id);
    $entitiesCount = count($entities);
    if (0 === $entitiesCount) {
        return;
    }
    $index = 0;
    $languages = @$postEntitiesService->getPostLanguages($id);
    echo "<div id=\"wordlift-bar\">";
    echo "<ul>";
    echo "<li class=\"separator\"></li>";
    foreach ($entities as $key => &$entity) {
        $index++;
        $link = admin_url("admin-ajax.php?action=wordlift.gotoentity&e=" . urlencode($key));
        $type = $postEntitiesService->getFirstValue($entity, "type");
        $shortType = strtolower(substr($type, strrpos($type, "/") + 1));
        $name = $postEntitiesService->getValueByLanguage($entity, "name", $languages);
        $name = htmlspecialchars($name, ENT_COMPAT, "UTF-8");
        if (empty($name)) {
            continue;
        }
        $title = $postEntitiesService->getValueByLanguage($entity, "title", $languages);
        $image = $postEntitiesService->getFirstValue($entity, "image");
        $description = $postEntitiesService->getValueByLanguage($entity, "description", $languages);
        $description = htmlspecialchars($description, ENT_COMPAT, "UTF-8");
        echo "<li itemscope itemtype=\"{$type}\" class=\"entity {$shortType}\">";
        echo "<a href=\"{$link}\">";
        echo "<h1 itemprop=\"name\">{$name}</h1>\n";
        if (!empty($title)) {
            echo "<h2 itemprop=\"title\">{$title}<h2>\n";
        }
        echo "<img onerror=\"this.parentNode.removeChild(this);\" itemprop=\"image\" src=\"{$image}\" />\n";
        echo "<p itemprop=\"description\">{$description}</p>\n";
        echo "</a>";
        echo "</li>";
        echo "<li class=\"separator\"></li>";
    }
    echo "</ul>";
    echo "<div id=\"wordlift-bar-switch\">";
    echo "</div>";
    echo "</div>";
}
开发者ID:gitter-badger,项目名称:wordlift-plugin,代码行数:58,代码来源:wordlift.php


示例12: get_recent_posts

 /**
  * Get recent posts
  *
  * Find all recent posts
  *
  * @since 1.0
  * @access public
  *
  * @return ARRAY Array of post objects
  */
 public function get_recent_posts($args = array())
 {
     extract($args);
     if ($network) {
         $sql = "SELECT * from " . $this->db->base_prefix . "network_posts where post_type = '" . $post_type . "' ORDER BY post_date DESC LIMIT 0, " . $numberposts;
         return apply_filters('pf_recent_network_posts_result', $this->db->get_results($sql, OBJECT), $sql);
     }
     return apply_filters('pf_recent_posts_result', wp_get_recent_posts($args, OBJECT), $args);
 }
开发者ID:bappi-d-great,项目名称:postify,代码行数:19,代码来源:class.recent-posts.php


示例13: recentposts

/**
* Get recent posts
* @example <?php recentposts(); ?>
*/
function recentposts()
{
    $args = array('numberposts' => '5', 'post_status' => 'publish');
    $recent_posts = wp_get_recent_posts($args);
    echo '<ul>';
    foreach ($recent_posts as $recent) {
        echo '<li><a href="' . get_permalink($recent["ID"]) . '" >' . $recent["post_title"] . '</a></li> ';
    }
    echo '</ul>';
}
开发者ID:hypenotic,项目名称:foodshare,代码行数:14,代码来源:recent-post.php


示例14: widget

 public function widget($args, $instance)
 {
     if (is_single()) {
         global $authordata, $post;
         echo $args['before_widget'];
         if (!empty($instance['title'])) {
             echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
         }
         $latest_args = array('author' => $authordata->ID, 'post__not_in' => array($post->ID), 'numberposts' => $instance['posts_no'], 'post_status' => 'publish');
         if ($instance['random']) {
             $latest_args['orderby'] = 'rand';
         }
         $latest_posts = wp_get_recent_posts($latest_args);
         if ($latest_posts) {
             echo '<ul>';
             foreach ($latest_posts as $latest) {
                 $post_categories = get_the_category($latest['ID']);
                 $post_categories_output = array();
                 foreach ($post_categories as $category) {
                     $category_output = '<a href="' . esc_url(get_category_link($category->cat_ID)) . '">' . esc_html($category->name) . '</a>';
                     array_push($post_categories_output, $category_output);
                 }
                 if (count($post_categories_output) > 0) {
                     $post_categories_output = ' ' . __('in', 'qtools') . ' ' . implode(', ', $post_categories_output) . ' ';
                 } else {
                     $post_categories_output = '';
                 }
                 echo '<li>';
                 if ($instance['thumbs'] && current_theme_supports('post-thumbnails')) {
                     echo '<div class="qtools-widget-post-thumb">';
                     if (has_post_thumbnail($latest['ID'])) {
                         echo '<a href="' . esc_url(get_permalink($latest['ID'])) . '">' . get_the_post_thumbnail($latest['ID'], 'thumbnail') . '</a>';
                     } else {
                         echo '<a href="' . esc_url(get_permalink($latest['ID'])) . '" title="' . apply_filters('the_title_attribute', $latest['post_title']) . '"><img src="' . plugin_dir_url(dirname(__FILE__)) . 'img/no-thumb.png" alt="' . apply_filters('the_title_attribute', $latest['post_title']) . '"></a>';
                     }
                     echo '</div>';
                 }
                 echo '<div class="qtools-widget-post-info">';
                 echo '<h4 class="qtools-widget-post-title"><a href="' . esc_url(get_permalink($latest['ID'])) . '">' . apply_filters('the_title', $latest['post_title']) . '</h4></a>';
                 if ($instance['meta']) {
                     echo '<div class="qtools-widget-post-meta"><a href="' . esc_url(get_author_posts_url($latest['post_author'])) . '">' . esc_html(get_the_author_meta('display_name', $latest['post_author'])) . '</a> ' . $post_categories_output . '</div>';
                 }
                 echo '</div>';
                 echo '</li>';
             }
             echo '</ul>';
             if ($instance['posts_no'] < count_user_posts($authordata->ID)) {
                 echo '<a href="' . esc_html(get_author_posts_url($authordata->ID)) . '" class="small-title link">' . esc_html__('More posts', 'qtools') . '</a>';
             }
         } else {
             esc_html_e('No posts found!', 'qtools');
         }
         echo $args['after_widget'];
     }
 }
开发者ID:qbkl,项目名称:qtools,代码行数:55,代码来源:qtools-widget-same-author.php


示例15: recentarticles_widget_sidebar

 function recentarticles_widget_sidebar()
 {
     // eiger Code Start
     echo '<li class="widget widget-recentarticlesuxebustyle"><div class="hd"><h3 class="widgettitle" style="float:left;">Recent</h3><a class="viewall mrx" style="float:right;" href="' . get_option('home') . '/archive/" title="View all posts">View all posts...</a></div><hr class="widget-hr" /><div class="bd"><ul>';
     $recent_posts = wp_get_recent_posts(array('numberposts' => '3', 'post_status' => 'publish'));
     foreach ($recent_posts as $post) {
         echo '<li class="uxebu-recent-articles mbl"><a class="article-sidebar-link" href="' . get_permalink($post["ID"]) . '" title="Look ' . $post["post_title"] . '" >' . $post["post_title"] . '</a><br />' . get_the_author_meta('display_name', $post["post_author"]) . ' | ' . get_the_time('F jS', $post["ID"]) . '</li> ';
     }
     echo '</ul></div></li>';
     // eiger Code Ende
 }
开发者ID:ciaranlm,项目名称:uxebu.com,代码行数:11,代码来源:recentarticles_widget.php


示例16: widget

    /**
     * How to display the widget on the screen.
     */
    function widget($args, $instance)
    {
        extract($args);
        global $wp_query, $post;
        global $THEMEREX_CURRENT_SIDEBAR;
        /* Our variables from the widget settings. */
        $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '');
        $number = isset($instance['number']) ? (int) $instance['number'] : '';
        $show_date = isset($instance['show_date']) ? (int) $instance['show_date'] : 0;
        $show_image = isset($instance['show_image']) ? (int) $instance['show_image'] : 0;
        $show_author = isset($instance['show_author']) ? (int) $instance['show_author'] : 0;
        $show_counters = isset($instance['show_counters']) ? (int) $instance['show_counters'] : 0;
        $category = isset($instance['category']) ? (int) $instance['category'] : 0;
        $show_counters = $show_counters ? get_theme_option("blog_counters") : '';
        $output = '';
        if ($THEMEREX_CURRENT_SIDEBAR == 'top') {
            $output .= '<div class="columnsWrap"><div class="columns1_2">';
        }
        $args = array('numberposts' => $number, 'offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'ignore_sticky_posts' => 1, 'suppress_filters' => true);
        if ($category > 0) {
            $args['category'] = $category;
        }
        $ex = get_theme_option('exclude_cats');
        if (!empty($ex)) {
            $args['category__not_in'] = explode(',', $ex);
        }
        $recent_posts = wp_get_recent_posts($args, OBJECT);
        $post_number = 0;
        foreach ($recent_posts as $post) {
            $post_number++;
            require themerex_get_file_dir('/templates/page-part-widgets-posts.php');
            if ($THEMEREX_CURRENT_SIDEBAR == 'top' && $post_number == round($number / 2)) {
                $output .= '
					</div><div class="columns1_2">
				';
            }
            if ($post_number >= $number) {
                break;
            }
        }
        if ($THEMEREX_CURRENT_SIDEBAR == 'top') {
            $output .= '</div></div>';
        }
        if (!empty($output)) {
            /* Before widget (defined by themes). */
            echo balanceTags($before_widget);
            /* Display the widget title if one was input (before and after defined by themes). */
            echo balanceTags($before_title) . esc_html($title) . balanceTags($after_title);
            echo balanceTags($output);
            /* After widget (defined by themes). */
            echo balanceTags($after_widget);
        }
    }
开发者ID:WestBayResidential,项目名称:wbrsorg,代码行数:56,代码来源:widget-recent-posts.php


示例17: show_recent_posts

function show_recent_posts($a, $c)
{
    extract(shortcode_atts(array('type' => 'blog'), $a));
    // There is no content in this shortcode, at least there shouldnt be!
    $args = array('numberposts' => '5', 'post_type' => $type);
    $recent_posts = wp_get_recent_posts($args);
    foreach ($recent_posts as $recent) {
        echo '<h2><a href="' . get_permalink($recent["ID"]) . '" title="Look ' . esc_attr($recent["post_title"]) . '" >' . $recent["post_title"] . '</a></h2>';
        echo '<p class="excerpt">' . $recent["post_excerpt"] . '<br/><span>Published: ' . $recent["post_date"] . '</span></p>';
        echo '<hr/>';
    }
}
开发者ID:besimhu,项目名称:legacy,代码行数:12,代码来源:shortcodes.php


示例18: cherry_generate_sitemap

 function cherry_generate_sitemap()
 {
     $file_dir = ABSPATH . 'sitemap.xml';
     if (get_option('do_generate_sitemap') == 'off') {
         if (file_exists($file_dir)) {
             unlink($file_dir);
         }
     } else {
         global $site_link;
         $main_changefreq = 'monthly';
         $main_priority = '1.0';
         $site_link = get_home_url('/');
         $get_recent_posts = wp_get_recent_posts(array('numberposts' => 1, 'post_type' => 'any', 'post_status' => array('publish', 'private')));
         $lastmod = get_option('page_on_front') != 0 ? get_post(get_option('page_on_front'))->post_modified : $get_recent_posts[0]['post_modified'];
         $lastmod_xml = '';
         if (null != $lastmod) {
             $_lastmod = explode(' ', $lastmod);
             $lastmod_xml = "\r\n\t\t\t<lastmod>" . $_lastmod[0] . "</lastmod>";
         }
         $sitemap_code = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n\t<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n\t\t<url>\r\n\t\t\t<loc>" . esc_url($site_link) . "</loc>" . $lastmod_xml . "\r\n\t\t\t<changefreq>" . $main_changefreq . "</changefreq>\r\n\t\t\t<priority>" . $main_priority . "</priority>\r\n\t\t</url>";
         $post_types = get_post_types(array('public' => true, '_builtin' => false), 'names', 'or');
         $sort_array = array('page' => '', 'post' => '', 'services' => '', 'portfolio' => '', 'slider' => '', 'team' => '', 'testi' => '', 'faq' => '');
         $post_types = array_merge($sort_array, $post_types);
         unset($post_types['optionsframework'], $post_types['wpcf7_contact_form']);
         query_posts(array('post_type' => $post_types, 'posts_per_page' => '-1'));
         if (have_posts()) {
             while (have_posts()) {
                 the_post();
                 if ($_POST['checked_' . get_post_type()] == "on") {
                     $post_changefreq = isset($_POST['changefreq_' . get_post_type()]) ? "\r\n\t\t\t<changefreq>" . $_POST['changefreq_' . get_post_type()] . "</changefreq>" : "";
                     $post_priority = isset($_POST['priority_' . get_post_type()]) ? "\r\n\t\t\t<priority>" . $_POST['priority_' . get_post_type()] . "</priority>" : "";
                     $sitemap_code .= "\r\n\t\t<url>\r\n\t\t\t<loc>" . esc_url(get_permalink()) . "</loc>\r\n\t\t\t<lastmod>" . get_the_modified_date('Y-m-d') . "</lastmod>" . $post_changefreq . $post_priority . "\r\n\t\t</url>";
                 }
             }
         }
         wp_reset_query();
         $sitemap_code .= "\r\n</urlset>";
         $sitemap = fopen($file_dir, "w");
         if (fwrite($sitemap, $sitemap_code)) {
             ping_search_system();
             update_option('sitemap_done', 'true');
             echo "Generate sitemap.xml done";
         } else {
             update_option('sitemap_done', 'false');
             echo "Generate sitemap.xml erroe";
         }
     }
     exit;
 }
开发者ID:woniu123360,项目名称:CherryFramework,代码行数:49,代码来源:sitemap-generator.php


示例19: get_data

 private function get_data()
 {
     $recent = array('show' => array(), 'fringe' => array());
     $fringe_arguments = array('numberposts' => 1, 'post_type' => 'episode', 'post_status' => 'publish');
     $recent['fringe'] = wp_get_recent_posts($fringe_arguments);
     $uncategorized = get_category_by_slug('uncategorized');
     $fringe = get_category_by_slug('tf');
     $show_arguments = array('numberposts' => 1, 'post_type' => 'episode', 'post_status' => 'publish', 'post__not_in' => array($recent['fringe'][0]['ID']));
     if ($uncategorized || $fringe) {
         $arguments['category__not_in'] = array($uncategorized->term_id, $fringe->term_id);
         //var_dump($arguments);
     }
     $recent['show'] = wp_get_recent_posts($show_arguments);
     return $recent;
 }
开发者ID:ryanmr,项目名称:convergence-theme,代码行数:15,代码来源:Most_Recent_Dashboard.php


示例20: widget

    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        $recent_posts = wp_get_recent_posts(array('numberposts' => 9, 'post_type' => 'wedding_registry', 'orderby' => 'post_date', 'post_status' => 'publish'));
        $i = 0;
        echo '
									<div class=" registry-row-mobile">
									<div id=&q 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_get_referer函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_get_raw_referer函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap