How to Determine a Post’s Last Edited Date?

If I got your question right, and you want posts created/modified between 3 years ago and today, try this query: SELECT p.ID, concat(‘http://www.toronto.com/restaurants/’, p.post_name) FROM wp_posts p WHERE p.post_type=”restaurant” AND p.post_status=”publish” AND p.post_modified > DATE_SUB(now(), INTERVAL 36 MONTH); Because your DATE_SUB returns something like this: NOW – 3 years, so, it’s something along the lines … Read more

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