1. 程式人生 > >wordpress部落格的安裝、製作,遇到的 問題

wordpress部落格的安裝、製作,遇到的 問題

1.wordpress常用外掛 實際的部落格頁面 http://13.57.57.223/

 

a.多欄目導航外掛使用,都可以根據名稱線上搜尋出來

外掛名稱:multi-level-navigation

功能使用:方便小白進行下拉導航欄的使用,延遲時間、樣式都可以自己去調。(推薦)如果你會jquery,可以自己編寫

實際效果:

b.瀑布流外掛使用

外掛名稱:post-grid

功能實用:可以實現前端介面的內容的瀑布流的使用。內容可根據類別、標籤、文章、等等選項去排版。

實際效果:

c.tags雲外掛

外掛名稱:tag-cloud,外掛在widgets裡面自行新增

功能實用:把標籤以雲塊顯示

實際效果:

d.slidbar外掛的使用

外掛名稱:AVH Extended Categories Widgets,搜尋安裝

功能實用:側邊欄,可以實現類目的劃分(功能較齊全,自行除錯)

實際效果:

 

如何實現類目頁、tag詳情頁、作者詳情頁的不同內容的劃分?

1.如何實現不同類目的列表頁模板編寫?

開啟 /home/centos/www/blog/blog/wp-content/themes/twentyseventeen中類目模板檔案

archive.php

常用的寫法就是if else

<?php

if ( is_category(5) ) {

include(TEMPLATEPATH . '/image_list.php');

} else {

include(TEMPLATEPATH . '/article_list.php');

}

?>

但我這裡選擇用swich case,迴圈,因為分類比較多的原因

switch ( is_category()) {
  case is_category(14): 
  include(TEMPLATEPATH . '/archive-video.php');
  break; 
  case is_category(17): 
  include(TEMPLATEPATH . '/archive-artical.php');
  break; }

大功告成!

2.如何實現tag標籤內容的詳情頁的編寫?

同上類目列表一樣的套路

<?php
switch ( is_tag()) {
  case is_tag(56): 
  include(TEMPLATEPATH . '/tag_led1.php');
  break; 
    case is_tag(53): 
  include(TEMPLATEPATH . '/tag_3d-printer.php');
  break; }

另外附上我的一個tag模板

<?php get_header(); ?>
<div class="wrap">
    <?php if ( have_posts() ) : ?>
        <header class="page-header">
            <?php
                the_archive_title( '<h1 class="page-title">', '</h1>' );
                the_archive_description( '<div class="taxonomy-description">', '</div>' );
            ?>
        </header><!-- .page-header -->
    <?php endif; ?>
<?php if(function_exists('wp_thumbnails_for_recent_posts')) { wp_thumbnails_for_recent_posts('num=20&width=75&height=75'); } ?>
    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">
<?php echo do_shortcode("[post_grid id='508']"); ?> 此處是呼叫pos_grid的瀑布流外掛
        </main><!-- #main -->
    </div><!-- #primary -->
    <?php get_sidebar(); ?>
</div><!-- .wrap -->
<?php get_footer();?>

好,tag標籤頁已經可以正藏實現

3.作者詳情頁如何實現?

<div id="post-grid-208" class="post-grid grid">

      <div class="grid-nav-top">
       <?php
    if(isset($_GET['author_name'])) :
        $curauth = get_userdatabylogin($author_name);
    else :
        $curauth = get_userdata(intval($author));
    endif;
    ?>

                        <em>Search results for</em>
                        <p>"<?php echo $curauth->nickname; ?>"</p>
                     
    <span>
     Descriptions:&nbsp;&nbsp;<?php the_author_description(); ?><br/>
     Email:&nbsp;&nbsp;<a href="mailto:<?php the_author_email(); ?>" target="_blank"><?php the_author_email(); ?></a>
    </span>
  
     
      </div>

      <div class="grid-items " id="">

      <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <div class="item mix skin even flat moons-products ">
          
          <div class="layer-media">
            <a href="<?php the_permalink() ?>" title="Permanent Link: <?php the_title(); ?>"><?php if ( has_post_thumbnail() ) : ?>
     <?php the_post_thumbnail( 'thumbnail' ); ?>
<?php else: ?>
    <?php if(function_exists('wp_thumbnails_for_homepage')) { wp_thumbnails_for_homepage(); } ?>
<?php endif; ?></a>

          </div>

          <div class="layer-content">
            <div class="element element_0 categories ">
          <?php the_category('&');?>
            </div>
             <a target="_blank" class="element element_1 title_link" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
           <p id="list_autghor1112"><?php the_author_posts_link(); ?></p>

            
            <div class="element element_3 post_date">
             <?php the_time('d M Y'); ?>
            </div>
          </div>

          </div>

        <?php endwhile; else: ?>
        <p><?php _e('No posts by this author.'); ?></p>

    <?php endif; ?>
      </div>
      </div>