Hot answers tagged

5

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, ...


4

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 ...


3

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, ...


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 ...


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 ...


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

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 ...


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 ...


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 ...


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

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



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