我在哪里可以找到WordPress中所有帖子/文章的目录?

时间:2017-03-03 23:42:57

标签: wordpress directory file-structure

我认为所有帖子都应该是wp-content / uploads / ...但我找不到它们。任何人都有我的帖子所在位置的想法?谢谢!

2 个答案:

答案 0 :(得分:0)

当您说“帖子”时,您指的是默认的帖子类型“帖子”,(管理员面板中的帖子标签)?

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

如果您需要通过模板访问它们,可以使用以下两种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...)
    }
}

答案 1 :(得分:-1)

帖子和文章存储在连接到wordpress的数据库中。您可以通过wordpress安装的根目录中的config.php了解如何连接它。

您的wordpress实例很可能正在使用MySQL(或Maria)数据库。你应该看到这样的条目:

<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

/** MySQL hostname */
define('DB_HOST', 'localhost');

为您的平台使用mysql客户端并连接到数据库。

如果您将localhost视为DB_HOST,您可能希望使用支持ssh连接的客户端,因为很可能您的mysql数据库仅绑定到端口3306上的localhost并且将会是更难以重新配置。