Hot answers tagged

3

You can use wpdb insert function. It's better in every way. It can care about data's escapeing itself and it's shorter. You can use your own query anyway but I would recommended this article for reading https://codex.wordpress.org/Data_Validation#Database


3

This doesn't sound like something coming from WordPress core. Quick search online got pretty slim results, but it seems to be asscociated with WP All Import plugin.


3

I agree with @Tom J Nowell: I'd suggest you remove it, or better yet just say "all rights reserved". But in the quest for answers, here's a suggestion using an option field to cache the years: /** * Get year range for posts. * * @return str */ function wpse_226627_get_copyright() { if ( ! $years = get_option( 'copyright' ) ) { $args ...


2

You can not replace the URL in the database using ctrl+f or any other "direct" method. You have to do a search & replace in the whole database in a way capable of keeping the validity of serialized data. There are several tools to do that serialized seach & replace. For example: Plugins like Better Search Replace, Velvet Blues Update URLs or ...


2

Try putting the table name inside quotes, like this SELECT * FROM `sparte-bogensport` Edit More info on why this happens: http://dev.mysql.com/doc/refman/5.7/en/identifiers.html


2

You should be using get_the_terms(). wp_get_post_terms() queries the db to get post term info, where as get_the_terms() returns the post term objects directly from the post term cache and only queries the db if that info is not available. By default, all post's terms are cached by the query being executed. EDIT I cannot comment (crappy mobile), but there ...


2

No, wpdb::delete does not handle anything other than WHERE field = X. You can just use the query method instead: $ids = implode( ',', array_map( 'absint', $ids ) ); $wpdb->query( "DELETE FROM table_name WHERE ID IN($ids)" );


2

This is actually not that hard, but you will have to excuse me for keeping it high level because this is just a stupid thing to do as all things which are security by obscurity. All you need to do is write your WPDB driver, which inherits the WPDB class. Place it in /wp-content/db.php file and make sure to initialize the global $wpdb object with your class. ...


1

Thanks to @Samuel Elh I manage to get this done. I added this to my order-confirmation.php after I included config.php require ('../wp-blog-header.php'); global $wpdb; global $current_user; get_currentuserinfo(); $skrivID = $current_user->ID; Then the insert query, I added the table I wanted the user ID stored in and used the ...


1

Personaly I would go with one table for all users. Having more tables with the same columns seems like a strange idea to me. The database will be a complete mess after you gwt more users. Make sure that the user_id is an index for the table and all your select/update/delete will be fine. The insert might have a very short but unsignificant delay after the ...


1

Alright! I understand that there is a custom wordpress login url. Also you need to login to a user's profile. If that's the case, I suggest a simple hack(If you legally have rights to access/modify the database). Try this: Go to cpanel and login to phpmyadmin and open the database for your website/blog. Find 'wp_options' table and search for a record ...


1

This is probably the root cause - https://core.trac.wordpress.org/changeset/36510. Core have moved from saving menus in $_POST to sending them as json encoded and then decode it into $_POST. I am not very familiar with how menus are sent to the server, but you probably either use the wrong hook, use the right hook but too early, or there is a bug in core.


1

Scheduled Post Guardian solved it. I guess scheduling strictly from database is not possible.


1

This will delete the post, the post metadata, and any terms used on the post. It will not delete the terms themselves. The PHP script is similar to this but slower. Replace {{your CPT}} with the identifier for your custom post type and pop this in your database on phpmyadmin or mysql. DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ...



Only top voted, non community-wiki answers of a minimum length are eligible