2013-05-08 28 views
0

我剛剛安裝了最新的WordPress的生成(3.5.1),當我像往常一樣添加循環它不會返回正常的結構。WordPress的循環不返回郵政結構

這是我的PHP:

<?php get_header(); ?> 
    <?php 
     $pageid = get_query_var('page_id'); 
     $postid = $post->ID; 
    ?> 

<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?> 
    <div class="wppost" id="post-<?php the_ID(); ?>"> 
    <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><h1><?php the_title(); ?></h1></a> 

     <div class="wpentry"><?php the_content(); ?></div> 
     </div> 
     <?php endwhile; ?> 
     <div class="wpnavigation"> 
      <?php posts_nav_link('','F&ouml;reg&aring;ende sida','N&auml;sta sida'); ?> 
     </div> 
    <?php else : ?> 
     <div class="wppost" id="post-<?php the_ID(); ?>"> 
     <h1><?php _e('Inl&auml;gget hittades inte'); ?></h1> 
     </div> 
    <?php endif; ?> 

這通常工作。但它現在所做的只是返回< p> -elements。

它不會返回wppost,the_title,wpentry或任何除了我在帖子本身寫的東西(只有文本到目前爲止)。

這是新事物或我做錯了什麼?我已經完成了這幾年,它的工作到目前爲止。我很難過。

這是從header.php文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head profile="http://gmpg.org/xfn/11"> 

<title><?php bloginfo('name'); ?><?php wp_title(); ?></title> 

<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> 
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please --> 

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" /> 
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" /> 
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" /> 
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" /> 
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> 

<?php wp_get_archives('type=monthly&format=link'); ?> 
<?php //comments_popup_script(); // off by default ?> 
<?php wp_head(); ?> 


</head> 
<body> 

    <div id="container"> 
     <div id="maincontainer"> 


      <div id="header"> 
       <a href="#" title="Descending Chaos"><img alt="Descending Chaos" src="<?php bloginfo('template_directory'); ?>/images/liveheader.png" /></a> 
      </div> 

      <div id="top"> 
       <div id="menu"> 
        <ul> 
         <?php wp_list_pages('title_li=','sort_column=menu_order'); ?> 
        </ul> 
       </div> 
       <div id="social"> 
        <ul> 
         <li><a href="#" title=""><img alt="Descending Chaos on Spotify" src="<?php bloginfo('template_directory'); ?>/images/spotlogo.png" /></a></li> 
         <li><a href="#" title=""><img alt="Descending Chaos on Reverbnation" src="<?php bloginfo('template_directory'); ?>/images/reverblogo.png" /></a></li> 
         <li><a href="#" title=""><img alt="Descending Chaos on Facebook" src="<?php bloginfo('template_directory'); ?>/images/facelogo.png" /></a></li> 
         <li><a href="#" title=""><img alt="Descending Chaos on YouTube" src="<?php bloginfo('template_directory'); ?>/images/youlogo.png" /></a></li> 
        </ul> 
       </div> 
      </div> 

編輯:更新了原來的職位有更多的代碼。

回答

0

如果您在循環之前運行<?php print_r($post); ?>,您應該能夠看到查詢。如果它不返回任何內容,那麼查詢有問題。你在這裏得到的代碼看起來很好。

+0

它返回未格式化的內容,即在這種情況下的文本。 – 2013-05-15 14:36:26

0

我將你的代碼添加到了我的開發網站,它在那裏工作,所以我不認爲這是你的代碼的問題。

嘗試在循環之前放置<?php wp_reset_query(); ?>。也許$wp_queryglobal post data在你的循環之前被修改並且需要被恢復。

+0

試過了,它沒有幫助。你是否使用相同的WordPress版本? 我已經使用標題中的內容更新了原始帖子。以及循環本身之前的幾行代碼。雖然我懷疑他們有什麼不同,因爲評論他們也沒有幫助。 – 2013-05-15 14:34:59

+0

該循環在哪裏?在哪個模板中? – user850010 2013-05-15 16:58:35