2017-10-13 74 views
0

我們的WordPress的網站被感染,我們被刪除的所有文件。我們現在只有數據庫,並希望從數據庫中提取所有信息,並將此副本放在其他站點上。從類別名稱的WordPress數據庫中調用所有帖子

所以我使用this php class來連接db並調用一些信息。我現在打電話給職位的數據,但也需要類別。

例如:

帖子標題,帖子內容,張貼分類

這裏是沒有的類別名稱

$posts = $db->get('c3624322676f_wp_posts'); 

我工作的代碼,但我不知道如何來這裏所稱的類別名稱。

這是我的HTML +的foreach

<table class="table table-hover"> 
    <thead class="thead-inverse"> 
    <tr> 
     <th>#</th> 
     <th>Title</th> 
     <th>Type</th> 
     <th>Content</th> 
     <th>Action</th> 
    </tr> 
    </thead> 
    <tbody> 
    <?php foreach ($posts as $post) : ?> 
    <tr> 
     <th scope="row"><?php echo $count++; ?><a href=""></th> 
     <td><?php echo $post['post_title']; ?></td> 
     <td><?php echo $post['post_type']; ?></td> 
     <td><?php echo strip_tags ($post['post_content']); ?></td> 
     <td> 
     <form action="" method="post"> 
     <input type="hidden" name="id" value="<?php echo $post['ID']; ?>" /> 
     <input style="cursor:pointer;" type="submit" class="btn btn-primary" value="Delete" /> 
     </form>  
     </td> 
    </tr> 
    <?php endforeach; ?> 
    </tbody> 
</table> 

回答

0

這應該工作

<table class="table table-hover"> 
    <thead class="thead-inverse"> 
    <tr> 
     <th>#</th> 
     <th>Title</th> 
     <th>Type</th> 
     <th>Content</th> 
     <th>Action</th> 
    </tr> 
    </thead> 
    <tbody> 
    <?php foreach ($posts as $post) : ?> 
    <tr> 
     <th scope="row"><?php echo $count++; ?><a href=""></th> 
     <td><?php echo $post['post_title']; ?></td> 
     <td><?php echo $post['post_type']; ?></td> 
     <td><?php echo strip_tags ($post['post_content']); ?></td> 

     <?php 
      $separator = ','; 
      $output = ''; 
      $categories = get_the_category($post['post_title']); 
      if ($categories){ 

       foreach($categories as $category) { 
        $output .= '<a href="'.get_category_link($category->term_id).'" title="' . esc_attr(sprintf(__("View all posts in %s"), $category->name)) . '">'.$category->cat_name.'</a>'.$separator; 
       } 

      echo trim($output, $separator); 
      } 
     ?>  
     <td> 
     <form action="" method="post"> 
     <input type="hidden" name="id" value="<?php echo $post['ID']; ?>" /> 
     <input style="cursor:pointer;" type="submit" class="btn btn-primary" value="Delete" /> 
     </form>  
     </td> 
    </tr> 
    <?php endforeach; ?> 
    </tbody> 
</table> 
+0

不會,因爲我們沒有WP不再只WP數據庫 –

+0

然後,它的簡單的下載新鮮的WordPress和數據庫連接新鮮的WP文件和更改您的網站的URL使用 1. wordpress數據庫:在wp_options 2.或者你也可以通過WP-config.php做到這一點 你可以海關於如何使用wp-config.php – Harry

+1

更改網站地址的WP文檔,那麼你將得到你的帖子在wordpress的帖子部分.... – Harry

相關問題