简体   繁体   English

使用php,mysql在Wordpress中创建动态内容

[英]dynamic content in Wordpress using php, mysql

I wish to create a Wordpress website that pulls data from a database. 我希望创建一个可以从数据库中提取数据的Wordpress网站。 For example: a database of cities, landmarks, events, etc. I understand that Wordpress uses an underlying database, but how do I create a separate database to store dynamic data that can be pulled useing normal sql queries? 例如:一个包含城市,地标,事件等的数据库。我知道Wordpress使用底层数据库,但是如何创建一个单独的数据库来存储可以使用常规sql查询提取的动态数据? thank you. 谢谢。

I understand that Wordpress uses an underlying database, but how do I create a separate database to store dynamic data 我了解Wordpress使用基础数据库,但是如何创建一个单独的数据库来存储动态数据

You can create a new database in mysql using the CREATE DATABASE command. 您可以使用CREATE DATABASE命令在mysql中创建一个新数据库。 For example: 例如:

CREATE DATABASE newdbname;

You can also utilize the Wordpress API for storing and retrieving custom data. 您还可以利用Wordpress API来存储和检索自定义数据。 This is a huge topic, but a good tutorial can be found here: 这是一个巨大的主题,但是可以在这里找到一个很好的教程:

http://code.tutsplus.com/tutorials/how-to-create-custom-wordpress-writemeta-boxes--wp-20336 http://code.tutsplus.com/tutorials/how-to-create-custom-wordpress-writemeta-boxes--wp-20336

Basically, you need to register a callback to the add_meta_boxes hook, by using the following Wordpress function: 基本上,您需要使用以下Wordpress函数将回调注册到add_meta_boxes挂钩:

add_action('add_meta_boxes', 'addMyCustomField');

And then write your call back function like so: 然后像这样编写您的回调函数:

function addMyCustomField(){

    add_meta_box('id', 'title', 'callback', 'post_type', 'context', 'priority', 'callback_args' );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM