SQL – JOIN last child

This is the solution I came up with: SELECT child_ID, posts.post_author, wp1.post_author FROM wp_posts posts LEFT JOIN ( SELECT MAX(ID) as child_ID, post_parent FROM wp_posts WHERE post_type=”ticket_reply” GROUP BY post_parent ) sl ON posts.ID = sl.post_parent INNER JOIN wp_posts wp1 on sl.child_ID = wp1.ID WHERE posts.ID = 1499

How to Import Multiple Values in custom field

The granularity of data in your example suggests that custom field (more so one with multiple values) would be wrong choice in first place. Think about it like this: only one dog might weight precisely 35.5kg — that is type of data appropriate for custom field multiple dogs (or dog breeds) might be of medium … Read more

How to write to wp-users table

You need to use wp_update_user function to update user info. Please see below code: <?php $user_id = 1; /* It would be dynamic in your case */ $display_name = $_POST[‘display_name’]; $user_id = wp_update_user( array( ‘ID’ => $user_id, ‘display_name’ => $display_name ) ); if ( is_wp_error( $user_id ) ) { // There was an error, probably … Read more

`#1215 – Cannot add foreign key constraint

In order to make the wp_posts(ID) a REFERENCE for the FOREIGN KEY, you should also set the wp_pageviews.ID‘s attributes as UNSIGNED and keep the same data type for the wp_pageviews.ID as (bigint) . Let me know if this helps you.

How to have WP Search widget index dynamically generated content?

Are families a custom post type? If so, they won’t be included in the default WP search. Try adding this to your theme’s functions.php function lauren_include_post_types_in_search($query) { if(is_search()) { $post_types = get_post_types(array(‘public’ => true, ‘exclude_from_search’ => false), ‘objects’); $searchable_types = array(); if($post_types) { foreach( $post_types as $type) { $searchable_types[] = $type->name; } } $query->set(‘post_type’, $searchable_types); … Read more

Options table – where does my values go?

There is indeed an options table (wp_options / prefix_options). You can the find full details on that table here: http://codex.wordpress.org/Database_Description#Table:_wp_options Options are meant to be globally accessible (not tied to individual posts), and you only need to know the option name/key. You can access that table and its values with the following functions: <?php $your_option … Read more

Local host to server import problem

A Google of wordpress wxr pulled up this link as the first result: https://wordpress.org/support/topic/xml-to-wxr-issue which suggests to If you paste the following line into your export file after the Language defining line in the section near the topyou should be good to go: <wp:wxr_version>1.1</wp:wxr_version> But I would strongly advise against this approach based on the … Read more

Datatabase error: Commands out of sync

This seems to be a problem with “orphaned SELECT statements”. It is described here in more detail. One solution would be to create a temporary table and modify my_acquireuserpasswd to save data to temp_table BEGIN DECLARE passwdtemp VARCHAR(64); DECLARE temp VARCHAR(4000); START TRANSACTION; SELECT id, passwd INTO uid1, passwdtemp FROM users WHERE name = name1; … Read more