add_action('pre_get_posts', array($this, 'my_test_plugin_pre_get_posts'));
function my_test_plugin_pre_get_posts($query) {
global $wpdb;
if ($query->is_main_query() && $query->is_search() && !empty($query->get('s'))) {
// Get and normalize the search string
$search_string = preg_replace('/\s+/', ' ', trim($query->get('s')));
// Generate variations for the search string
$search_variations = [
$search_string,
str_replace(' ', '-', $search_string),
str_replace('-', ' ', $search_string),
str_replace(' ', '', $search_string),
str_replace('-', '', $search_string),
];
// Build SQL conditions for the search variations
$search_conditions = [];
foreach (array_unique($search_variations) as $variation) {
$search_conditions[] = "{$wpdb->posts}.post_title COLLATE utf8mb4_general_ci LIKE '%" . $wpdb->esc_like($variation) . "%'";
$search_conditions[] = "wp_postmeta.meta_value COLLATE utf8mb4_general_ci LIKE '%" . $wpdb->esc_like($variation) . "%'";
}
// Combine all conditions
$custom_where = '(' . implode(' OR ', $search_conditions) . ')';
// Query the database for matching post IDs
$query_sql = "
SELECT DISTINCT {$wpdb->posts}.ID
FROM {$wpdb->posts}
LEFT JOIN {$wpdb->postmeta} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id
WHERE {$custom_where}
AND {$wpdb->posts}.post_type = 'product'
AND {$wpdb->posts}.post_status = 'publish'
";
$post_ids = $wpdb->get_col($query_sql);
// Log debugging information
error_log('SQL Query: ' . $query_sql);
error_log('Matched Post IDs: ' . print_r($post_ids, true));
// If results are found, modify the query
if (!empty($post_ids)) {
error_log('IF: ');
$query->set('post__in', $post_ids); // Limit the query to these post IDs
$query->set('posts_per_page', -1); // Ensure all matching posts are shown
} else {
error_log('ELSE: ');
$query->set('post__in', [0]); // No results
}
// Log the modified query
// error_log('Modified Query: ' . print_r($query, true));
}
The code above generates and dumps this SQL:
SELECT DISTINCT wp_posts.ID
FROM wp_posts
LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
WHERE (wp_posts.post_title COLLATE utf8mb4_general_ci LIKE '%magtech 9a%' OR wp_postmeta.meta_value COLLATE utf8mb4_general_ci LIKE '%magtech 9a%' OR wp_posts.post_title COLLATE utf8mb4_general_ci LIKE '%magtech-9a%' OR wp_postmeta.meta_value COLLATE utf8mb4_general_ci LIKE '%magtech-9a%' OR wp_posts.post_title COLLATE utf8mb4_general_ci LIKE '%magtech9a%' OR wp_postmeta.meta_value COLLATE utf8mb4_general_ci LIKE '%magtech9a%')
AND wp_posts.post_type = 'product'
AND wp_posts.post_status = 'publish'
The problem is when it comes to the search.php page, it shows that there are no matching posts.
So search strings: “magtech 9a” returns 5 results when checked againts the SQL generated
“magtech – 9a” returns 7 results.
Here is a $wp_query dump from the search.php page.
WP_Query Object
(
[query] => Array
(
[s] => magtech 9a
)
[query_vars] => Array
(
[s] => magtech 9a
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[meta_key] =>
[meta_value] =>
[preview] =>
[sentence] =>
[title] =>
[fields] =>
[menu_order] =>
[embed] =>
[category__in] => Array
(
)
[category__not_in] => Array
(
)
[category__and] => Array
(
)
[post__in] => Array
(
[0] => 21093
[1] => 17667
[2] => 21089
[3] => 21096
[4] => 21103
)
[post__not_in] => Array
(
)
[post_name__in] => Array
(
)
[tag__in] => Array
(
)
[tag__not_in] => Array
(
)
[tag__and] => Array
(
)
[tag_slug__in] => Array
(
)
[tag_slug__and] => Array
(
)
[post_parent__in] => Array
(
)
[post_parent__not_in] => Array
(
)
[author__in] => Array
(
)
[author__not_in] => Array
(
)
[search_columns] => Array
(
)
[posts_per_page] => -1
[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] => 1
[update_post_term_cache] => 1
[update_menu_item_cache] =>
[lazy_load_term_meta] => 1
[update_post_meta_cache] => 1
[post_type] => any
[nopaging] => 1
[comments_per_page] => 50
[no_found_rows] =>
[search_terms_count] => 2
[search_terms] => Array
(
[0] => magtech
[1] => 9a
)
[search_orderby_title] => Array
(
[0] => wp_posts.post_title LIKE '{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}magtech{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}'
[1] => wp_posts.post_title LIKE '{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}9a{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}'
)
[order] => DESC
)
[tax_query] => WP_Tax_Query Object
(
[queries] => Array
(
)
[relation] => AND
[table_aliases:protected] => Array
(
)
[queried_terms] => Array
(
)
[primary_table] => wp_posts
[primary_id_column] => ID
)
[meta_query] => WP_Meta_Query Object
(
[queries] => Array
(
)
[relation] =>
[meta_table] =>
[meta_id_column] =>
[primary_table] =>
[primary_id_column] =>
[table_aliases:protected] => Array
(
)
[clauses:protected] => Array
(
)
[has_or_relation:protected] =>
)
[date_query] =>
[queried_object] =>
[queried_object_id] =>
[request] => SELECT wp_posts.*
FROM wp_posts
WHERE 1=1 AND wp_posts.ID IN (21093,17667,21089,21096,21103)
AND (
(wp_posts.post_title LIKE '%magtech 9a%')
OR (wp_posts.post_excerpt LIKE '%magtech 9a%')
OR (wp_posts.post_content LIKE '%magtech 9a%')
OR EXISTS (
SELECT * FROM wp_postmeta
WHERE post_id = wp_posts.ID
AND meta_key = '_sku'
AND meta_value LIKE '%magtech 9a%'
)
) AND ((wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'wc-manual-review' OR wp_posts.post_status = 'acf-disabled'
OR wp_posts.post_status = 'private')) OR (wp_posts.post_type = 'page' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'wc-manual-review' OR wp_posts.post_status = 'acf-disabled'
OR wp_posts.post_status = 'private')) OR (wp_posts.post_type = 'attachment' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'wc-manual-review' OR wp_posts.post_status = 'acf-disabled'
OR wp_posts.post_status = 'private')) OR (wp_posts.post_type = 'newsletter' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'wc-manual-review' OR wp_posts.post_status = 'acf-disabled'
OR wp_posts.post_status = 'private')) OR (wp_posts.post_type = 'accounting-spread' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'wc-manual-review' OR wp_posts.post_status = 'acf-disabled'
OR wp_posts.post_status = 'private')) OR (wp_posts.post_type = 'q-and-a' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'wc-manual-review' OR wp_posts.post_status = 'acf-disabled'
OR wp_posts.post_status = 'private')) OR (wp_posts.post_type = 'product' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'wc-manual-review' OR wp_posts.post_status = 'acf-disabled'
OR wp_posts.post_status = 'private')))
ORDER BY (CASE WHEN wp_posts.post_title LIKE '{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}magtech 9a{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}' THEN 1 WHEN wp_posts.post_title LIKE '{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}magtech{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}' AND wp_posts.post_title LIKE '{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}9a{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}' THEN 2 WHEN wp_posts.post_title LIKE '{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}magtech{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}' OR wp_posts.post_title LIKE '{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}9a{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}' THEN 3 WHEN wp_posts.post_excerpt LIKE '{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}magtech 9a{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}' THEN 4 WHEN wp_posts.post_content LIKE '{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}magtech 9a{7f90af97b8b683298c974e6d7bb2a1460659f885df295a3ee307a368fe158315}' THEN 5 ELSE 6 END), wp_posts.post_date DESC
[posts] => Array
(
)
[post_count] => 0
[current_post] => -1
[before_loop] => 1
[in_the_loop] =>
[comment_count] => 0
[current_comment] => -1
[found_posts] => 0
[max_num_pages] => 0
[max_num_comment_pages] => 0
[is_single] =>
[is_preview] =>
[is_page] =>
[is_archive] =>
[is_date] =>
[is_year] =>
[is_month] =>
[is_day] =>
[is_time] =>
[is_author] =>
[is_category] =>
[is_tag] =>
[is_tax] =>
[is_search] => 1
[is_feed] =>
[is_comment_feed] =>
[is_trackback] =>
[is_home] =>
[is_privacy_policy] =>
[is_404] =>
[is_embed] =>
[is_paged] =>
[is_admin] =>
[is_attachment] =>
[is_singular] =>
[is_robots] =>
[is_favicon] =>
[is_posts_page] =>
[is_post_type_archive] =>
[query_vars_hash:WP_Query:private] => af1656ef835d9ed8f7093e50a6057df5
[query_vars_changed:WP_Query:private] => 1
[thumbnails_cached] =>
[allow_query_attachment_by_filename:protected] =>
[stopwords:WP_Query:private] => Array
(
[0] => about
[1] => an
[2] => are
[3] => as
[4] => at
[5] => be
[6] => by
[7] => com
[8] => for
[9] => from
[10] => how
[11] => in
[12] => is
[13] => it
[14] => of
[15] => on
[16] => or
[17] => that
[18] => the
[19] => this
[20] => to
[21] => was
[22] => what
[23] => when
[24] => where
[25] => who
[26] => will
[27] => with
[28] => www
)
[compat_fields:WP_Query:private] => Array
(
[0] => query_vars_hash
[1] => query_vars_changed
)
[compat_methods:WP_Query:private] => Array
(
[0] => init_query_flags
[1] => parse_tax_query
)
)
]]>Hello,
I have tried all possible features for Google Image scrapping and Google image (API). Query based on category, taxonomie, custom field not working. None of these options are working. Instead the plugin is searching based on the Title.
I use WP All Import integration. I have tried to create a custom field and there dynamically assign values. In the older versions it was working and I did scrap different images to product variations based on the custom query. Now even if I select the value, it is not working. And the custom query gives the following errors:
Import Error
Warning: Undefined array key "custom_field" in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 456
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Warning: Array to string conversion in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1411
Fatal error: Uncaught TypeError: urlencode(): Argument #1 ($string) must be of type string, array given in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php:1416 Stack trace: #0 /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php(1416): urlencode() #1 /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php(1050): Magic_Post_Thumbnail_Generation->MPT_Get_Parameters() #2 /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php(707): Magic_Post_Thumbnail_Generation->MPT_Process_Image_Block() #3 /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/inc/wp_all_import.php(42): Magic_Post_Thumbnail_Generation->MPT_create_thumb() #4 /var/www/html/wp-includes/class-wp-hook.php(324): Magic_Post_Thumbnail_WP_All_Import->MPT_fired_wpallimport() #5 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #6 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action() #7 /var/www/html/wp-content/plugins/wp-all-import-pro/models/import/record.php(3634): do_action() #8 /var/www/html/wp-content/plugins/wp-all-import-pro/controllers/admin/import.php(2809): PMXI_Import_Record->process() #9 /var/www/html/wp-content/plugins/wp-all-import-pro/wp-all-import-pro.php(773): PMXI_Admin_Import->process() #10 /var/www/html/wp-includes/class-wp-hook.php(324): PMXI_Plugin->adminInit() #11 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #12 /var/www/html/wp-includes/plugin.php(517): WP_Hook->do_action() #13 /var/www/html/wp-admin/admin.php(175): do_action() #14 {main} thrown in /var/www/html/wp-content/plugins/magic-post-thumbnail-premium/admin/class-magic-post-thumbnail-generation.php on line 1416
{"code":"internal_server_error","message":"
There has been a critical error on this website. Please check your site admin email inbox for instructions. If you continue to have problems, please try the support forums<\/a>.<\/p>
Learn more about troubleshooting WordPress.<\/a><\/p>","data":{"status":500,"error":{"type":1,"message":"Uncaught TypeError: urlencode(): Argument #1 ($string) must be of type string, array given in \/var\/www\/html\/wp-content\/plugins\/magic-post-thumbnail-premium\/admin\/class-magic-post-thumbnail-generation.php:1416\nStack trace:\n#0 \/var\/www\/html\/wp-content\/plugins\/magic-post-thumbnail-premium\/admin\/class-magic-post-thumbnail-generation.php(1416): urlencode()\n#1 \/var\/www\/html\/wp-content\/plugins\/magic-post-thumbnail-premium\/admin\/class-magic-post-thumbnail-generation.php(1050): Magic_Post_Thumbnail_Generation->MPT_Get_Parameters()\n#2 \/var\/www\/html\/wp-content\/plugins\/magic-post-thumbnail-premium\/admin\/class-magic-post-thumbnail-generation.php(707): Magic_Post_Thumbnail_Generation->MPT_Process_Image_Block()\n#3 \/var\/www\/html\/wp-content\/plugins\/magic-post-thumbnail-premium\/admin\/inc\/wp_all_import.php(42): Magic_Post_Thumbnail_Generation->MPT_create_thumb()\n#4 \/var\/www\/html\/wp-includes\/class-wp-hook.php(324): Magic_Post_Thumbnail_WP_All_Import->MPT_fired_wpallimport()\n#5 \/var\/www\/html\/wp-includes\/class-wp-hook.php(348): WP_Hook->apply_filters()\n#6 \/var\/www\/html\/wp-includes\/plugin.php(517): WP_Hook->do_action()\n#7 \/var\/www\/html\/wp-content\/plugins\/wp-all-import-pro\/models\/import\/record.php(3634): do_action()\n#8 \/var\/www\/html\/wp-content\/plugins\/wp-all-import-pro\/controllers\/admin\/import.php(2809): PMXI_Import_Record->process()\n#9 \/var\/www\/html\/wp-content\/plugins\/wp-all-import-pro\/wp-all-import-pro.php(773): PMXI_Admin_Import->process()\n#10 \/var\/www\/html\/wp-includes\/class-wp-hook.php(324): PMXI_Plugin->adminInit()\n#11 \/var\/www\/html\/wp-includes\/class-wp-hook.php(348): WP_Hook->apply_filters()\n#12 \/var\/www\/html\/wp-includes\/plugin.php(517): WP_Hook->do_action()\n#13 \/var\/www\/html\/wp-admin\/admin.php(175): do_action()\n#14 {main}\n thrown","file":"\/var\/www\/html\/wp-content\/plugins\/magic-post-thumbnail-premium\/admin\/class-magic-post-thumbnail-generation.php","line":1416}},"additional_errors":[]}
]]>add_action(‘elementor/query/my_custom_filter’, function ($query) {
$meta_query = array('relation' => 'AND');
// Check if CAS Number is provided, using '=' comparison
if (!empty($_GET['cas_number'])) {
$meta_query[] = array(
'key' => 'CAS Number', // Correct key name without underscore
'value' => sanitize_text_field($_GET['cas_number']),
'compare' => '=' // Exact match
);
}
// Check if Supplier is provided, using LIKE comparison
if (!empty($_GET['supplier'])) {
$meta_query[] = array(
'key' => 'Supplier', // Correct key name for supplier
'value' => sanitize_text_field($_GET['supplier']),
'compare' => 'LIKE' // Partial match
);
}
// Check if Other Search Term is provided, using '=' comparison
if (!empty($_GET['other_search_term'])) {
$meta_query[] = array(
'key' => 'Other Search Term', // Correct key name without underscore
'value' => sanitize_text_field($_GET['other_search_term']),
'compare' => '=' // Exact match
);
}
// Check if Estimated Delivery Time is provided, using LIKE comparison
if (!empty($_GET['estimated_delivery_time'])) {
$meta_query[] = array(
'key' => 'Estimated Delivery Time', // Correct key name for delivery time
'value' => sanitize_text_field($_GET['estimated_delivery_time']),
'compare' => 'LIKE' // Partial match
);
}
// Check if Minimum Price and Maximum Price are provided, using BETWEEN comparison
if (!empty($_GET['min_price']) && !empty($_GET['max_price'])) {
$meta_query[] = array(
'key' => 'Price', // WooCommerce standard price field
'value' => array(sanitize_text_field($_GET['min_price']), sanitize_text_field($_GET['max_price'])),
'type' => 'NUMERIC',
'compare' => 'BETWEEN'
);
}
// Only apply the meta query if it's not empty
if (!empty($meta_query)) {
$query->set('meta_query', $meta_query);
}
});
The only other custom code i have is to hide and reveal the hidden container of a product. It hide the details of the product by default and reveal it when a chevron arrow is toggled. It works sometimes and stop working. Here is the code:
document.addEventListener(‘DOMContentLoaded’, function() {
// Get all the buttons and chemical detail containers
const detailsBtns = document.querySelectorAll(‘.details-btn’);
const chemicalDetailsContainers = document.querySelectorAll(‘.chemical-details’);
// Hide all chemical details containers by default
chemicalDetailsContainers.forEach(function(container) {
container.style.display = 'none';
});
// Attach click event to each button
detailsBtns.forEach(function(btn, index) {
btn.addEventListener('click', function() {
const chemicalDetails = chemicalDetailsContainers[index];
if (chemicalDetails.style.display === 'none') {
chemicalDetails.style.display = 'block';
} else {
chemicalDetails.style.display = 'none';
}
});
});
});
]]>In practice I should extract the products that correspond to the skus present in a custom mysql table relating to the logged in user.
Thank’s
]]>What I wish to do is have a custom page (for example, “dbtest.php”) and pull meta values from the WP database. I’m only being partially successful. All the data I need is in the usermeta table. At this time, I don’t need to join any other tables.
I need to return the meta values for the following meta keys:
I only want to return the records where one, two, or three of the three textarea fields have values.
Following is the code I’m using that partially works. I’m having two major issues.
// Return Metadata ONLY.
$IDmax = $wpdb->get_results("select max(user_id) FROM $wpdb->usermeta");
for ($x = 0; $x <= 18; $x++) {
$results1 = get_user_meta( $x, 'first_name', true );
$results2 = get_user_meta( $x, 'last_name', true );
$results3 = get_user_meta( $x, 'nickname', true );
$results4 = get_user_meta( $x, 'textarea_zknsk', true );
$results5 = get_user_meta( $x, 'textarea_o0nn8', true );
$results6 = get_user_meta( $x, 'textarea_fjy8e', true );
echo "<pre><strong>First Name: </strong>";
print_r($results1);echo "</br>";
echo "<strong>Last Name: </strong>";
print_r($results2);echo "</br>";
echo "<strong>Nickname: </strong>";
print_r($results3);echo "</br>";
echo "<strong>Board Member Notes: </strong>";
print_r($results4);echo "</br>";
echo "<strong>Board Secretary Notes: </strong>";
print_r($results5);echo "</br>";
echo "<strong>Board Treasurer Notes: </strong>";
print_r($results6);echo "</pre>";
}
Any help will be greatly appreciated.
]]>I started learning Pods and Elementor Pro as they seem to fit my cost needs best. But I’m also up for the challenge to learn more.
I created CPTs for Services and Projects, for which I created relationships ‘service-relation’.
Now I built a single page template for Services in Elementor, and I would like that page to show only related projects in the loop carousel at the bottom of the page.
What would be the custom query command and how to assign an Query ID to it in Code Snippets?
Would anybody be willing to help me out? I’d love to learn that also for my other project.
Thanks a lot in advance!
Cheers,
Jonas
]]>I started learning Pods and Elementor Pro as they seem to fit my cost needs best. But I’m also up for the challenge to learn more.
I created CPTs for Services and Projects, for which I created relationships ‘service-relation’.
Now I built a single page template for Services in Elementor, and I would like that page to show only related projects in the loop carousel at the bottom of the page.
What would be the custom query command and how to assign an Query ID to it in Code Snippets?
Would anybody be willing to help me out? I’d love to learn that also for my other project
@edtwodth @joebonbon
Thanks a lot in advance!
Cheers,
Jonas
]]>
I would like to show a list of upcoming events as in the below link under “Our Programs” section with the immediate upcoming one highlighted on the left side and the list on the right side with the option of vertical scrolling.
Someone please guide me on how to accomplish this, using free version of Events Manager. In case if it is not feasible with this, are there any alternatives available to accomplish this without having to go for paid plugins or extensions.. Any help would be highly appreciated.
]]>This application isn’t published yet. I can provide the SQL block if necessary. I also presented this problem as a comment in the https://wpdataaccess.com/docs/query-builder/writing-queries web page – sorry for the duplication. I tried to submit a ticket through Premium Support, but was unable to do it – since I only have a local URL for development, the interface does not accept it.
]]>