New answers tagged

3

Custom tables can simplify your code, improve performance and help avoiding conflicts with WordPress’ schema changes in the future. Don’t hesitate to use one if you need it. The extra complexity comes from two other factors: maintenance and multisite. Maintenance: manual or automatic backups might omit custom tables, so there is a tiny risk that the data ...


0

In fact, adding db table is not very much that expensive as you think. If you configure it well. Suppose, before you create the table it is really you need it. If so, you just need to follow up wordpress database creating table standard. They have their guide line. Another thing to note, you database table never ever should hurt wordpress core functionality. ...


0

Use get_categories first to get all the post categories to use in the form, then loop through them to display a multicheck input... function hierarchical_category_inputs ($cat, $indent) { $cats = get_categories('hide_empty=false&orderby=name&order=ASC&parent='.$cat); $indent++; if ($cats) { foreach ($cats as $cat) { ...


1

Use this: $query = new WP_Query( array( 'cat' => 4 ) ); Where 4 is the ID of the top-level category (Blackburn). This query will in clude subcats. Reference - WP_Query


0

I can't offer you an explanation for what happened. But what I can unfortunately tell you is that you'll have no luck on the WP side of things. There is no backup of that data. I guess your best bet is still trying to save this MySQL table. Have you contacted the hosting provider? Maybe they have a backup. Anyway you should ask this at some of the sister ...


0

There are multiple ways to do this: 1. Add multiple columns to the table with the strings you have to localize. E.g. one column for German, one for English, and so on. And then get the string from the appropriate column. This is perfect if the number of languages stays more or less constant (you have to change the DB for every new language). 2. Add a ...


5

In addition to the other answers and the typo pointed out by @birgire, here is another approach. First, we will set the title as a hidden custom field, but we will first remove the words a, and and the. You can use the following code. You must remove this code completely as soon as you have loaded any page once. If you have a huge site with a ton of posts, ...


5

The Problem I think there's a typo in there: The name of the filter is posts_fields not post_fields. That could explain why the title2 field is unknown, because it's definition isn't added to the generated SQL string. Alternative - Single filter We can rewrite it to use only a single filter: add_filter( 'posts_orderby', function( $orderby, \WP_Query $q ...


8

An easier way may be to go through and change the permalink slug on those posts that need it (under the title on the post writing screen) and then just use that for ordering instead of the title. ie. use post_name not post_title for sorting... This would also mean that your permalink may be different if you use %postname% in your permalink structure, ...


2

After writing those two lines in wp-config.php, your users data will be shared between both installations, but both installations will also need to have the same cookie parameters, so in wp-config.php file of your second installation, modify the COOKIE_DOMAIN like this: define('COOKIE_DOMAIN', '.{yoursite.com}'); //replace with URL of first site ...


0

You're right that the problem is a result of the explode on semi-colons. We can use the dbdelta_queries filter to fix it. In this solution we're assuming that all queries start with CREATE, INSERT or UPDATE. If you have queries you're running through dbDelta where this isn't the case, the preg_match line will need adjusting or it won't work correctly. ...


0

You can use get_post_meta( $post_id ) to retrieve all of the meta for a post. It will give you more than you need but you can filter it out after. Here is the code reference - https://developer.wordpress.org/reference/functions/get_post_meta/


0

Here is a plugin that can accomplish that. https://wordpress.org/plugins/better-search-replace/ Just select wp_posts and wp_posts_meta, check the GUID box, and replace image/bmp with image/jpeg and .bmp with .jpg I changed 5000 images in about 20 seconds.


2

THE SHORT Export sudo mysqldump -u root -pPASSWORD DBNAME > filename.sql Import wp db import filename.sql THE LONG So this turns out to be very painless. The server dump is exactly what WP-CLI needs to import. REMOTE sudo mkdir backup Make a directory for the file. sudo chown -f -R ec2-user:group backup Set permissions to the directory ...


2

You can try use: MySQL WorkBench or other MySQL Client program; SSH to the Server and connect from the command prompt; Use PHPMyAdmin (make sure to password protect and set the right configuration); If you are really in need of an extra level of security you may want to consider setting up a VPN between your computer and the server where MySQL is ...


0

It does not create tables, it stores data the "WordPress way" in the postmeta table, which is common to all WordPress functions. Because it's common to all WordPress functions, the ID's are going to be out of sequence for Yoast data, because it's going to be "commingled" with much other data that gets stored in that table. As to your question about the ...


0

You can solve issue by this way(If issue with plugin/theme related): Deactivating your plugins by ftp or the file manager by changing the name of the plugins folder to plugins-old. If that works activate them one by one until you find the problem. Switch theme to any default (just for a moment) by using ftp or the file manager on your hosted account to ...


1

In general, it is a bad idea to upgrade from such an old version to new version in one go. In your case, a huge amount of changes was done between the release of v3.8.1 and v4.4.1 which invloved changes in the db. I'm not sure which is the best option here to repair the db as it seems that you cannot log into the site. What I would suggest is, revert back ...


1

For every meta value saved there is a second row prefixed with _ that stores what field definition this value refers to. Do not delete it. Your example additionally is a repeater which makes it more complex but the docs has a nice explanation: $ParentName_$RowNumber_$ChildName So you have a repeater field called carousel which has a subfield called ...


0

If there is more than 1-2 meta related to your custom post type, the possibility (or necessity) of complex user searches based on that custom data, then custom table. Otherwise complex JOINs done on meta tables to pull posts by querying 2-3 criterion at the same time on meta table will slow the site down. Considerably, based on concurrent users. If you have ...


1

Non core database tables are a must if your data is more complex than WordPress post model, it is going to be huge, and it has a lot of meta details which will be searched. EAV format WordPress uses for its post meta does not lend itself well to multi-criterion search. If you divide your meta into many entries, you will have numerous entries per post in ...


2

Fixed query select p.ID as order_id, p.post_date, i.order_item_name, max( CASE WHEN im.meta_key = '_product_id' and i.order_item_id = im.order_item_id THEN im.meta_value END ) as Prod_ID from wp_posts as p, wp_postmeta as pm, wp_woocommerce_order_items as i, wp_woocommerce_order_itemmeta ...


0

By itself wodb doesn't do (and probably can't) anything extra to what the DB will do. When the table is locked you will probably wait longer for a response or fail on timeout.


0

Do you want this dashboard to be on the front-end or the back-end (inside /wp-admin)? For the first case you just need to create a page with a custom page template for it, put all your dashboard logic into that template, and redirect your users to the page after they login (check this answer for the hook to use, you will need to place it inside the theme's ...


0

That little hack just "fixes" the URL when you call the home or siteurl options, image paths are not affected by that. Depending on where you want to show images, you could apply a filter to the_content, search for your URL and add your subfolder to it. Then you could show images in your post content. I don´t know if there is a better, "wider" filter to ...



Top 50 recent answers are included