【问题标题】:Where can I find the directory of all my posts/articles in WordPress?我在哪里可以找到我在 WordPress 中的所有帖子/文章的目录?
【发布时间】:2017-03-03 23:42:57
【问题描述】:

我认为所有帖子都应该在 wp-content/uploads/... 但我找不到它们。有人知道我的帖子在哪里吗?谢谢!

【问题讨论】:

  • 它们不会存储在数据库中吗?
  • 哦,是的,我完全忘记了数据库...谢谢!!

标签: wordpress directory file-structure


【解决方案1】:

当您说“帖子”时,您指的是默认帖子类型“帖子”(管理面板中的帖子选项卡)吗?

如果这是您所指的,您可以通过您的数据库直接访问它们。所有帖子都存储在您的数据库中,而不是作为实际文件。

如果您需要通过模板访问它们,您可以使用以下两种 wordpress 方法之一:

$args = array(
    'post_type' => 'post
);

args 数组将是您的查询设置。

$posts = get_posts($args);
print_r($posts); // this will give you 5 posts, you can increase the number with the argument 'posts_per_page' => x

您可以使用简单的 foreach 循环遍历这些数据。

第二种方法:

$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
    while ( $the_query->have_posts() ) {
         //post data (title, content, etc...)
    }
}

【讨论】:

  • 谢谢!很有帮助!
  • 谁能告诉我们在哪里执行这些功能?我的意思是在哪个文件中?
猜你喜欢
  • 1970-01-01
  • 2013-05-06
  • 1970-01-01
  • 1970-01-01
  • 2015-04-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多