2015-12-04 63 views
1

大家好我是一個新的wordpress我嘗試創建每個帖子的頁面細節。但是我不能,我希望當我在帖子上點擊鏈接並轉到帖子的頁面詳細信息如何創建每個帖子wordpress的頁面細節?

這是我的代碼get each崗位:

single.php: 


<?php 
/** 
* The Template for displaying all single posts 
* 
* @package WordPress 
* @subpackage Twenty_Fourteen 
* @since Twenty Fourteen 1.0 
*/ 
?> 
<?php get_header(); ?> 

    <div id="primary" class="content-area"> 
     <div id="content" class="site-content" role="main"> 
      <?php 
       // Start the Loop. 
       while (have_posts()) : the_post(); 

        /* 
        * Include the post format-specific template for the content. If you want to 
        * use this in a child theme, then include a file called called content-___.php 
        * (where ___ is the post format) and that will be used instead. 
        */ 
        get_template_part('content', get_post_format()); 

        // Previous/next post navigation. 
        twentyfourteen_post_nav(); 

        // If comments are open or we have at least one comment, load up the comment template. 
        if (comments_open() || get_comments_number()) { 
         comments_template(); 
        } 
       endwhile; 
      ?> 
     </div><!-- #content --> 
    </div><!-- #primary --> 
<?php get_footer(); ?> 
<h1>hello</h1> 

,這我的活動頁面:

<?php 

    $zerif_total_posts = get_option('posts_per_page'); /* number of latest posts to show */ 

    if(!empty($zerif_total_posts) && ($zerif_total_posts > 0)): 

     echo '<section class="latest-news" id="latestnews">'; 

      echo '<div class="container">'; 

       /* SECTION HEADER */ 

       echo '<div class="section-header">'; 

        $zerif_latestnews_title = get_theme_mod('zerif_latestnews_title'); 

        /* title */ 
        if(!empty($zerif_latestnews_title)): 

         echo '<h2 class="dark-text">' . $zerif_latestnews_title . '</h2>'; 

        else: 

         echo '<h2 class="dark-text">' . __('Our Client','zerif-lite') . '</h2>'; 

        endif; 

       /* our Client */ 

        if(is_active_sidebar('menu_client')): 
        echo '<div id="menu_client">'; 

        dynamic_sidebar('menu_client'); 
        echo '</div>'; 
        endif; 

        /* subtitle */ 
        $zerif_latestnews_subtitle = get_theme_mod('zerif_latestnews_subtitle'); 

        if(!empty($zerif_latestnews_subtitle)): 

         echo '<div class="dark-text section-legend">'.$zerif_latestnews_subtitle.'</div>'; 

        endif; 

       echo '</div><!-- END .section-header -->'; 

       echo '<div class="clear"></div>'; 

       echo '<div id="carousel-homepage-latestnews" class="carousel slide" data-ride="carousel">'; 

        /* Wrapper for slides */ 

        echo '<div class="carousel-inners" role="listbox">'; 


         $zerif_latest_loop = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $zerif_total_posts, 'order' => 'DESC','ignore_sticky_posts' => true)); 

         $newSlideActive = '<div class="item active">'; 
         $newSlide  = '<div class="item">'; 
         $newSlideClose = '<div class="clear"></div></div>'; 
         $i_latest_posts= 0; 
         $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
         $page_id = get_the_ID(); 
         if ($zerif_latest_loop->have_posts()) : 

          while ($zerif_latest_loop->have_posts()) : $zerif_latest_loop->the_post(); 

           $i_latest_posts++; 

           if (!wp_is_mobile()){ 

             if($i_latest_posts == 1){ 
              echo $newSlideActive; 
             } 
             else if($i_latest_posts % 4 == 1){ 
              echo $newSlide; 
             } 

             echo '<div class="col-sm-3 latestnews-box">'; 

              echo '<div class="latestnews-img">'; 

               echo '<a class="latestnews-img-a" href="'.get_permalink().'" title="'.get_the_title().'">'; 

                if (has_post_thumbnail()) : 
                 the_post_thumbnail(); 
                else: 
                 echo '<img src="'.esc_url(get_template_directory_uri()).'/images/blank-latestposts.png" alt="'.get_the_title().'" />'; 
                endif; 

               echo '</a>'; 

              echo '</div>'; 

              echo '<div class="latesnews-content">'; 

               echo '<h3 class="latestnews-title"><a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a></h3>'; 

               the_excerpt(); 

              echo '</div>'; 

             echo '</div><!-- .latestnews-box"> -->'; 

             /* after every four posts it must closing the '.item' */ 
             if($i_latest_posts % 4 == 0){ 
              echo $newSlideClose; 
             } 

           } else { 

            if($i_latest_posts == 1) $active = 'active'; else $active = ''; 

            echo '<div class="item '.$active.'">'; 
             echo '<div class="col-md-3 latestnews-box">'; 
              echo '<div class="latestnews-img">'; 
               echo '<a class="latestnews-img-a" href="'.get_permalink().'" title="'.get_the_title().'">'; 
                if (has_post_thumbnail()) : 
                 the_post_thumbnail(); 
                else: 
                 echo '<img src="'.esc_url(get_template_directory_uri()).'/images/blank-latestposts.png" alt="'.get_the_title().'" />'; 
                endif; 
               echo '</a>'; 
              echo '</div>'; 
              echo '<div class="latesnews-content">'; 
               echo '<h3 class="latestnews-title"><a href="'.get_the_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a></h3>'; 
               the_excerpt(); 
              echo '</div>'; 
             echo '</div>'; 
            echo '</div>'; 
           } 

          endwhile;    
         endif; 
         $max_num_pages = $loop->max_num_pages; 
        echo sofg_pagination($max_num_pages,$paged,$page_id); 

         if (!wp_is_mobile()) { 
          // if there are less than 10 posts 
          if($i_latest_posts % 4!=0){ 
           echo $newSlideClose; 
          } 
         } 
         wp_reset_postdata(); 

        echo '</div><!-- .carousel-inner -->'; 

        /* Controls */ 
        echo '<a class="left carousel-control" href="#carousel-homepage-latestnews" role="button" data-slide="prev">'; 

        echo '</a>'; 
        echo '<a class="right carousel-control" href="#carousel-homepage-latestnews" role="button" data-slide="next">'; 

        echo '</a>'; 
       echo '</div><!-- #carousel-homepage-latestnews -->'; 

      echo '</div><!-- .container -->'; 
     echo '</section>'; 

endif; 


?> 

,我希望當我點擊鏈接後它去evenet_page_detail.php看到內容後的細節誰可以幫我pleast

+0

http://westecmedia.com/events-2/ – user307709

+0

活動頁面本網站我只是繼續從另一個網絡開發商 – user307709

+0

現在的鏈接好,但當我點擊每個職位。其丟失的描述文本 – user307709

回答

1

WordPress有一個特定的方式來創建頁面以正確訪問它們。 相反命名您的網頁evenet_page_detail.php的請它作爲single.php

您可以獲取有關從頭開始創建模板這裏https://codex.wordpress.org/Stepping_into_Templates

+0

我創建single.php並添加我的代碼 – user307709

+0

當我clt ont每個帖子我什麼也沒有 – user307709

+0

你可以請分享我的網站鏈接,所以我可以檢查 – vikramp

1

的WordPress擁有Template Hierarchy更多信息。如果您爲這些帖子使用自定義帖子類型,則可以創建一個新的single-{post-type}.php文件,並且當您輸入此詳細帖子url時,使用的文件就是這個。

此外,您可以爲某些帖子創建自定義模板文件。這是一個tutorial。基本上你需要創建一個新的文件,例如evenet_page_detail.php和在第一線包括:

<?php /* Template Name: My template name */ ?> 

然後在後管理員需要在右列選擇器選擇該模板的名稱。當你選擇這個模板時,這個文件將被用來顯示這篇文章的細節。

+0

這個兄弟{}是什麼? – user307709

+0

我是一個新的WordPress的,所以你有我的兄弟代碼? – user307709

+0

如果您使用自定義帖子類型命名,例如'event',您需要創建一個'singe-event.php',如果您希望顯示這些自定義帖子類型的詳細信息的特殊模板。 –

相關問題