Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

post-meta

Custom query, multiple custom keys

I’m not an SQL expert, but I would think you might have to JOIN twice to pick two distinct rows out of wp_postmeta: $featuredquery = ” SELECT wposts.* FROM $wpdb->posts wposts JOIN $wpdb->postmeta article_level ON ( wposts.ID = article_level.post_id AND article_level.meta_key = ‘article_level’ ) JOIN $wpdb->postmeta article_genre ON ( wposts.ID = article_genre.post_id AND article_genre.meta_key = … Read more

Categories post-meta Tags customization, post-meta, query-string

Is it possible to retrieve a post and its metadata at the same time?

It’s not a single step, but it’s easy to write & handle in code: get_post_custom() gives you all attached meta data. But be aware: Everything comes as array, even when it´s a single value. So // Ever entry comes like this. // Example single value for ‘Hair color’: Array( [0] => Array( ‘Brown’ ) )

Categories post-meta Tags get-posts, post-meta

get_post_meta is showing file url in url bar

You should check the urls in your Custom field. This function adding http for invalid url. function addhttp($url) { if (!preg_match(“~^(?:f|ht)tps?://~i”, $url)) { $url = “http://” . $url; } return $url; } And finally: <?php function addhttp($url) { if (!preg_match(“~^(?:f|ht)tps?://~i”, $url)) { $url = “http://” . $url; } return $url; } ?> <a href=”https://wordpress.stackexchange.com/questions/275288/<?php echo … Read more

Categories post-meta Tags post-meta

get_post_meta() not work for the first post inside the loop

In that case try to create custom sql query like this. global $wpdb; $query = “SELECT meta_value FROM wp_postmeta WHERE post_id=your post id AND meta_key=’class’; $results = $wpdb->get_row($query) ; echo $results->meta_value;

Categories post-meta Tags post-meta

$wpdb class updating meta_value using Ajax [closed]

$wpdb class updating meta_value using Ajax [closed]

Categories post-meta Tags ajax, meta-query, post-meta

need some assistance with the checkboxes (selecting/deselecting featured posts)

This appears to be a general PHP warning, you’re supplying an incorrect argument in a foreach loop. $_POST[‘list_id’] is expected to be an array or any other (iteratable object), when no checkboxes are checked I assume $_POST[‘list_id’] is completely undefined. $_POST[‘list_id’] = isset( $_POST[‘list_id’] ) ? (array) $_POST[‘list_id’] : array(); Adding this before you iterate … Read more

Categories post-meta Tags post-meta

need to add add user names to the post for later retrieval or removal

Decided going to use comments system to implement this feature.

Categories post-meta Tags post-meta

Compare string with post id in wpdb and do stuff when match is found

This is what I ended up using, turned out I didn’t need to apply the meta value to the child pages since I used another approach. Hopefully it’s useful for someone. $row = $wpdb->get_row(“SELECT * FROM wp_posts WHERE ID =’$post_id'”); $new_order = $order[$page[‘depth’]]; $new_order = $wpdb->escape($new_order); $current_order = $row->menu_order; if($current_order != $new_order) { switch ($new_order) … Read more

Categories post-meta Tags menu-order, post-meta, wpdb

Get a row from a separate table by matching a posts meta_key to a tables ID column

global $wpdb; /* grab meta value, it is assumed you know the post id ($id) in question */ $dot_number = get_post_meta( $id, ‘dot_number’, true ); /* grab all rows with matching value in ‘dot_number’ column */ $matches_query = $wpdb->get_results( “SELECT * FROM ” . $wpdb->prefix . “csadata ” . “WHERE dot_number = ” . $dot_number, … Read more

Categories post-meta Tags get-row, post-meta, wpdb

Editing does not change post_name

Editing does not change post_name

Categories post-meta Tags post-editor, post-meta, title, urls
Older posts
Newer posts
← Previous Page1 … Page31 Page32 Page33 … Page51 Next →
+ More

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
Next Page »
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress