I'm trying to insert / modify / delete items from a Wordpress menu from a MYSQL query in a separate WordPress file.
Does anyone know how wordpress menus work at the database level?
They're nothing else than a default postype, specifically: nav_menu_item.
So like the rest of the postypes they are in the post table or wp_posts if you use that prefix.
As all the rest of postypes their meta values are stored in postmeta/wp_postsmeta with the corresponding id.
Related
I'm working on a project (WordPress) that using a custom data directory to store any_table.ibd (InnoDB files) files (mandatory requirement from customer).
So my requirement is, need to add DATA DIRECTORY = '/path/to/dir/' sql part to every create table statement.
Default WordPress create tables statements already customized via mu plugin with dbdelta_create_queries hook.
Is there any way to do same thing for any plugin that installed in WordPress site ?
Sample Query
CREATE TABLE table1 (id int PRIMARY KEY, name varchar (50))
DATA DIRECTORY = 'path/to/data/directory/'
I have 2 projects, one in Wordpress, and the other one in Laravel 4.2.
Recently i had to merge both projects into one Laravel 4.2 App using jgrossi/corcel. This was my only option.
Everything works fantastic! I can even post directly into Wordpress without logging into Wordpress to get posts, comments, etc.
But there is something I can't figure out. Wordpress is using Jetpack for subscribers. The laravel app needs a field to add more subscribers. I have very little experience in Wordpress.
Is it possible to add subscribers from outside Wordpress directly into the database? If not, is there a way to use a Jetpack plugin outside of Wordpress?
Yes you can add new users in database with subscribers role.
Wordpress stores the users data in wp_users table and its meta info in wp_usermeta. So follow the following steps
Add a new entry in wp_users table. As a sample here is entry from my wp_users table. You can submit values for these attributes using your normal laravel form with post request.
Add its related data in wp_usermeta table. Here you need to set two key value attributes against user_id of newly inserted record.
meta_key = wp_capabilites and meta_value = a:1:{s:10:"subscriber";b:1;}. As you can note the meta_value for wp_capabilities is in serialzed form.
meta_key = show_admin_bar_front and meta_value = true.
So you added a new user with subscriber role.
i have 2 wordpress websites A and B.
if A somehow changes (adding a post , editing a post , deleting a post ) , B needs to change as well .
so in A by using a php robot which is checking database every couple of minutes , i,ve created a json feed for added and edited posts of A .
it's easy to track added/edited posts by checking wp_posts table . but i can't find a way to know which posts have been deleted ( Delete Permanently ).
this script is suppose to be portable and usable for people who are not programmer , so i dont want to use wordpress functions or do any change/addition to wordpress system .
so is there any way to find deleted posts by checking the database or something like that ?
You can check for posts in the trash by using the query:
SELECT * FROM `wp_posts` WHERE `post_status` = 'trash'
but if you are trying to find posts that have been removed from the database you will need to either track the missing IDs in the wp_posts table or add some functionality to track when a post is deleted. You can do this by using the delete_post action hook in your theme:
function my_tracking_function() {
// Put ID into new database table
}
add_action( 'delete_post', 'my_tracking_function', 1 );
And then pass that table to the other site for processing. Once both sites are synced you can run a cleanup routine to empty the tracking table. I realize that this is partially using Wordpress functionality, but the passing of the table data can be done outside of Wordpress using SQL.
i currently have a problem with my admin section. I'd like to add some infos about my users and display these infos in the array.
Here a screenshot : view of table
You can see i've added some columns.
When you click on user account the fieds corresponding to these columns are present and filled.
The info is in the sql base too. But nothing displayed in the table :(
You have to use the User Meta to be Wordpress friendly
Here is how to add a user meta : http://codex.wordpress.org/Function_Reference/add_user_meta
But if you prefer you can use a meta manager like this one: http://wordpress.org/extend/plugins/user-meta-manager/
I have created a plugin to upload the csv to wordpress. what i want to know is how to create the slug of the title while inserting it into wp_posts.
Current i am using normal mysql query to insert the data.
Any help?
Thanks
The post_name column in wp_posts contains the slug. For generating the slug itself use sanitize_title