New answers tagged database
0
Thanks to webaware for their answer.
Here's some copy/pasta for anyone looking for a quick start. This takes an entry ID and retrieves the lead and form from that. In this case I'm using the URL to pass the value. e.g. somedomain.com?entry=123.
<?php
$lead_id = $_GET['entry'];
$lead = RGFormsModel::get_lead( $lead_id );
$form = ...
0
You could filter 'query' (you get the complete SQL here) and search for the post type in that. Then switch the database depending on what you found.
But I don’t think this would work well:
You might end up with the same post ID used multiple times (in each DB) and some strange side effects (comments, taxonomies).
Some queries include multiple post types; ...
1
Wordpress has a table called *wp_term_relationships* to keep track of several types of relationships, including post - category.
Let's go table by table:
wp_posts - holds all posts,pages, and other content. You want to poll all rows that have -> post_type = post . You might want to poll only published posts -> post_status = publish
wp_term_relationships - ...
0
A Wordpress update will not drop (clear) your DB. You could backup your DB before the update in case there is some problem, but that is not at all likely to happen... having a backup on hand is a good idea anyway.
2
No. it does not .
And your post will not be deleted
Updates from the wordpress interface regard only the core FILES. not the DB.
However, sometimes, between versions, a db upgrade can be made which is mainly reordering or fixing DB. Not deleting entries.
It is at any rate recommended to do a db backup before any upgrade / update.
1
It is possible to use custom post types and only some features WordPress adds to that API. In fact, this is the default: When you call register_post_type(), the default value for public is FALSE. No UI, no query var, no rewrite rules, list tables or public visibility. You can leave public => FALSE, turn on only the features you need and use your custom ...
0
I may be misinterpreting your question, it could use some more detail, but I think the old site must have had a plugin installed. Posts and their statuses are not displayed in any of the default WordPress dashboard widgets.
The only two plugins that I know that do something like that are Post Status Menu Items—by pure coincidence, I'm the author of that ...
2
The plugin should use the API, not some made-up SQL. addslashes() is not safe enough anyway.
$user = get_user_by( 'email', 'user@example.com' );
echo $user->ID;
Besides that, the user tables are almost the same, there are just some tighter restrictions for user names in multi-site, because new sub domains could be made from the names.
0
There is a SQL query in the theme file /themes/ExtraGrid/content-single.php, and it is asking for a column that doesn’t exist.
This seems to be a commercial theme, so we can just guess why that query exists. Maybe you forgot to set a required theme option, or your tables are just incomplete.
3
The obvious advantage of user meta is that you can use the WordPress API to record and retrieve these extra columns, without writing extra PHP classes or SQL queries. The wp_usermeta table is pretty well indexed, in fact, it uses one row per field (rather than one column if you use a custom table), and you don't have to worry about performance. Using the ...
0
You hook a function to save_post (for saves and updates) or publish_post for publication only. The second hook is really a variable hook of the form {$new_status}_{$post->post_type} so it will be different if you aren't dealing with a post post type.
function do_on_publish_wpse_98177($id) {
// your code; $id is the post ID
}
...
1
Rather than using a custom table or post meta to store the tag information you will probably find a simpler solution if you investigate the Custom Taxonomy support within WordPress.
You can register one (or more) custom taxonomies against the attachment post type.
The following Codex pages are a good place to start:
...
2
The best way would be to use the built-in Options API to add info to the wp_options table.
To add the option:
http://codex.wordpress.org/Function_Reference/add_option
To read the option value:
http://codex.wordpress.org/Function_Reference/get_option
1
Use the Options API.
add_option( 'option_name', $values );
update_option( 'option_name', $values );
get_option( 'option_name', $default_value );
delete_option( 'option_name' );
You can store non-scalar values here too, an array with two entries for example. Make sure to use a unique name for the option name, prefix everything.
3
Tax Query Limits
A Taxonomy Query in WordPress supports the following three arguments for the operator parameter: IN, NOT IN and AND. So it basically can't do what you're trying to do. Not even with advanced (tax_query) Queries.
Meta Query and possibilities
You'll want to move your concept a bit and work with post meta fields/data. The WP_Query uses the ...
0
If you have already installed w3tc I would strongly suggest that you try to optimize the settings.
Use page caching via memcache and a static asset CDN. This gives a performance boost of about ~95% for not logged in users for me on every page i used it.
Page caching, database caching and object caching are particularly usefull in taking load of the ...
0
function jal_install() {
global $jal_db_version;
$sql = "CREATE TABLE IF NOT EXISTS WP_AWESOME_TABLES (
id mediumint(9) NOT NULL AUTO_INCREMENT,
PRIMARY KEY id (id)
);";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
add_option( "jal_db_version", $jal_db_version );
}
...
1
I have encountered the same kind of issue before, as you have already noted down the problem boiled down to mysql not accepting too many connections, The solution we implemented was to apply proper caching (check how often the cache is invalidated and other caching settings) and upgrade the mysql server.
As a quick fix, you could flush the connections on ...
2
Avoid serialized whenever you can. It is slow to read and you cannot really search for it.
Use custom tables – more than one:
One for the relationship between users, tags and images: user_id, tag_id and image_id.
One for tag meta data, your attributes, if I understand that right: tag_id, meta_1, meta_2 …
Now you can look up for each attachment ID if ...
0
I've used this:
update_post_meta( $post->ID, 'your_meta_data'.$user_id, 'your_value' ); <= this will add for each user 1 field for that post, in db.
All Good :)
Top 50 recent answers are included