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

How to selected which tags to print, instead of printing the whole tag list?

By get_the_tags() you receive an array of tags attached to the current post. So you could do the following: $tags = get_the_tags(); $tag_ids_to_print = array( 1, 2, 3 ); //List of Tag IDs which you want to be printed $print_tags = array(); if( is_array( $tags ) ){ foreach( $tags as $tag ){ if( in_array( $tag->term_id, … Read more

Categories post-meta Tags post-meta, tags

Post meta as array looks like string instead of array

Your data will be serialized, if you save non-scalar values (e.g. array, object) as post meta. You must unserialize it: $subs = get_post_meta( $post->ID ); $subs[‘_q1_subs’][0] = unserialize($subs[‘_q1_subs’][0]);

Categories post-meta Tags array, post-meta

get_post_meta producing white screen of death

You have to add this line to the top of single.php global $post; or, use get_the_ID(), as Divi does in the same single.php if( get_post_meta( get_the_ID(), ‘store-url’, true) !== ”) {…

Categories post-meta Tags post-meta

How can I change the tag contents of individual WordPress posts?

I would read this article, its from Yoast. I don’t think you are understanding what the focus keyword feature does. This article talks about that as well as how adding the keyword meta tag is a waste of time (in most cases). I wouldn’t worry about adding it BUT if you still want to I … Read more

Categories post-meta Tags plugin-wp-seo-yoast, post-meta, wp-head

Like & Dislike functionality using JavaScript

I hope you are doing well. Here, I am sharing code for recording likes. The code for single.php have the javascript code for making an ajax call to a wp function. This wp function have the code to store like expressions and it will return you the total number of like expressions recorded on post. … Read more

Categories post-meta Tags post-meta, user-meta

Adding new value to existing meta key

Use the following instead of add_post_meta: update_post_meta($post_id, ‘when’ $date); add_post_meta does just that, adds a new meta key every time, including duplicates in your case. update_post_meta also incorporates add_post_meta if a key doesn’t exist, but updates an existing key. For reference: http://codex.wordpress.org/Function_Reference/update_post_meta If you want to store rolling dates in an array, you would simply … Read more

Categories post-meta Tags post-meta

Read post meta values, only if posts are public

Yes, do an INNER JOIN, something like this should work: $values = $wpdb->get_col($wpdb->prepare(” SELECT meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id WHERE meta_key= %s AND {$wpdb->posts}.post_status=”publish”” ,$metakey )); I changed $wpdb->get_results() to $wpdb->get_col() since it looks like you are just selecting a single column of data as an array. I also added $wpdb->prepare() … Read more

Categories post-meta Tags post-meta, select, wpdb

get_post_meta not extracting title,permalink and posttype

Post metas are used for storing custom data that you want to store and retrieve yourself. The default post data post type, title, permalink are not saved in post meta. You can retrieve post_type and title using get_post() function which returns a WP_Post object. For permalink you need to use get_permalink() function like this. $post … Read more

Categories post-meta Tags post-meta

cleaning up safely wordpress wp_postmeta table

The only generic semi-automatic procedure I can think of would be to delete post meta where the post_id is invalid. SELECT * FROM {$wpdb->postmeta} as pm LEFT JOIN {$wpdb->posts} as p ON pm.post_id = p.ID WHERE p.ID IS NULL I wrote a SELECT and not a DELETE because I don’t trust that to work in … Read more

Categories post-meta Tags customization, optimization, post-meta, sql

Trying to get property of non-object error using get_post_meta()

$post is never set on init when I test this– function topSub( $Trunckvalue = null ) { global $post; var_dump($post); } add_action( ‘init’, ‘topSub’ ); The earliest hook I can find (by experimentation, not a canonical statement) is wp. Aditionally, $post is set on archive pages as well as “single” pages. On those archive pages … Read more

Categories post-meta Tags post-meta
Older posts
Newer posts
← Previous Page1 … Page30 Page31 Page32 … 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