<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                **1. wordpress調用最新文章** WordPress最新文章的調用可以使用一行很簡單的模板標簽wp_get_archvies來實現. 代碼如下: ~~~ <?php get_archives(‘postbypost’, 10); ?> (顯示10篇最新更新文章) ~~~ 或者 ~~~ <?php wp_get_archives(‘type=postbypost&limit=20&format=custom’); ?> ~~~ 后面這個代碼顯示你博客中最新的20篇文章,其中format=custom這里主要用來自定義這份文章列表的顯示樣式。具體的參數和使用方法你可 以參考官方的使用說明- `wp_get_archvies。(fromat=custom也可以不要,默認以UL列表顯示文章標題。)` 補充: 通過WP的query_posts()函數也能調用最新文章列表, 雖然代碼會比較多一點,但可以更好的控制Loop的顯示,比如你可以設置是否顯示摘要。具體的使用方法也可以查看官方的說明。 **2. wordpress調用隨機文章** ~~~ <?php $rand_posts = get_posts(‘numberposts=10&orderby=rand’); foreach( $rand_posts as $post ) : ?> <!–下面是你想自定義的Loop–> <li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li> <?php endforeach; ?> ~~~ 復制代碼 **3. wordpress調用最新留言** 下面是我之前在一個Wordpress主題中代到的最新留言代碼,具體也記不得是哪個主題了。該代碼直接調用數據庫顯示一份最新留言。其中 LIMIT 10限制留言顯示數量。綠色部份則是每條留言的輸出樣式。 ~~~ <?php global $wpdb; $sql = “SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,30) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = ’1′ AND comment_type = ” AND post_password = ” ORDER BY comment_date_gmt DESC LIMIT 10″; $comments = $wpdb->get_results($sql); $output = $pre_HTML; foreach ($comments as $comment) { $output .= “n<li>”.strip_tags($comment->comment_author) .”:” . ” <a href=”” . get_permalink($comment->ID) . “#comment-” . $comment->comment_ID . “” title=”on ” . $comment->post_title . “”>” . strip_tags($comment->com_excerpt) .”</a></li>”; } $output .= $post_HTML; echo $output;?> ~~~ **4.wordpress調用相關文章** 在文章頁顯示相關文章 ~~~ <?php $tags = wp_get_post_tags($post->ID); if ($tags) { $first_tag = $tags[0]->term_id; $args=array( ‘tag__in’ => array($first_tag), ‘post__not_in’ => array($post->ID), ‘showposts’=>10, ‘caller_get_posts’=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <li><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title_attribute(); ?>”><?php the_title();?> <?php comments_number(‘ ‘,’(1)’,’(%)’); ?></a></li> <?php endwhile; } } wp_reset_query(); ?> ~~~ **5.wordpress調用指定分類的文章** ~~~ <?php $posts = get_posts( “category=4&numberposts=10″ ); ?> <?php if( $posts ) : ?> <ul><?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <li> <a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></a> </li> <?php endforeach; ?> </ul> <?php endif; ?> ~~~ **6.wordpress去評論者鏈接的評論輸出** ~~~ <?php global $wpdb; $sql = “SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type,comment_author_url, SUBSTRING(comment_content,1,14) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = ’1′ AND comment_type = ” AND post_password = ” ORDER BY comment_date_gmt DESC LIMIT 10″; $comments = $wpdb->get_results($sql); $output = $pre_HTML; foreach ($comments as $comment) { $output .= “ <li>”.strip_tags($comment->comment_author).”:” . ” <a href=”” . get_permalink($comment->ID) . “#comment-” . $comment->comment_ID . “” title=”on ” . $comment->post_title . “”>” . strip_tags($comment->com_excerpt).”</a></li>”; } $output .= $post_HTML; echo $output;?> ~~~ **7.wordpress調用含gravatar頭像的評論輸出** ~~~ <?php global $wpdb; $sql = “SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,10) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = ’1′ AND comment_type = ” AND comment_author != ‘鄭 永’ AND post_password = ” ORDER BY comment_date_gmt DESC LIMIT 10″; $comments = $wpdb->get_results($sql); $output = $pre_HTML; foreach ($comments as $comment) { $output .= “ <li>”.get_avatar(get_comment_author_email(‘comment_author_email’), 18). ” <a href=”” . get_permalink($comment->ID) . “#comment-” . $comment->comment_ID . “” title=”” . $comment->post_title . ” 上的評論”>”. strip_tags($comment->comment_author) .”: “. strip_tags($comment->com_excerpt) .”</a></li>”; } $output .= $post_HTML; $output = convert_smilies($output); echo $output; ?> ~~~ 上面代碼把comment_author的值改成你的ID,18是頭像大小,10是評論數量。 **8.wordpress調用網站統計大全** ***8-1、日志總數:*** <?php $count_posts = wp_count_posts(); echo $published_posts = $count_posts->publish;?> ***8-2、草稿數目:*** <?php $count_posts = wp_count_posts(); echo $draft_posts = $count_posts->draft; ?> ***8-3、評論總數:*** <?php echo $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->comments”);?> ***8-4、成立時間:*** <?php echo floor((time()-strtotime(“2008-8-18″))/86400); ?> ***8-5、標簽總數:*** <?php echo $count_tags = wp_count_terms(‘post_tag’); ?> ***8-6、頁面總數:*** <?php $count_pages = wp_count_posts(‘page’); echo $page_posts = $count_pages->publish; ?> ***8-7、分類總數:*** <?php echo $count_categories = wp_count_terms(‘category’); ?> ***8-8、鏈接總數:*** <?php $link = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->links WHERE link_visible = ‘Y’”); echo $link; ?> ***8-9、用戶總數:*** <?php $users = $wpdb->get_var(“SELECT COUNT(ID) FROM $wpdb->users”); echo $users; ?> ***8-10、最后更新:*** ~~~ <?php $last = $wpdb->get_results(“SELECT MAX(post_modified) AS MAX_m FROM $wpdb->posts WHERE (post_type = ‘post’ OR post_type = ‘page’) AND (post_status = ‘publish’ OR post_status = ‘private’)”);$last = date(‘Y-n-j’, strtotime($last[0]->MAX_m));echo $last; ?> ~~~ ***8-11.wordpress 非插件調用評論表情*** ~~~ <!–smilies–> <?php function wp_smilies() { global $wpsmiliestrans; if ( !get_option(‘use_smilies’) or (empty($wpsmiliestrans))) return; $smilies = array_unique($wpsmiliestrans); $link=”; foreach ($smilies as $key => $smile) { $file = get_bloginfo(‘wpurl’).’/wp-includes/images/smilies/’.$smile; $value = ” “.$key.” “; $img = “<img src=”{$file}” alt=”{$smile}” />”; $imglink = htmlspecialchars($img); $link .= “<a href=”#commentform” title=”{$smile}” onclick=”document.getElementByIdx_x(‘comment’).value += ‘{$value}’”>{$img}</a>&nbsp;”; } echo ‘<div class=”wp_smilies”>’.$link.’</div>’; } ?> <?php wp_smilies();?> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看