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

get_post_meta returns NULL in front-end, but correct result in back-end

Not 100% sure I understand the question or problem, but this ought to work, I think: add_action( ‘the_post’, ‘output_my_custom_field’); function output_my_custom_field( $post_object ) { $post_id = $post_object->ID; // why the conditional (and redundant !empty) ? // if ( !empty($post_id) ) ) { $my_custom_field = get_post_meta( $post_id, ‘my_custom_field’, true ); var_dump($my_custom_field); // see above // } … Read more

Categories custom-post-types Tags custom-post-types, post-meta

Save CTP post meta different values each day without overwriting previous values

I’m agree with the comment of @birgire, but if you really want to do it with custom fields, I think it’s better to group all datas for a post in one custom field in an array. After, you only need to use get_post_meta to get older values and add the new one in the array. … Read more

Categories custom-post-types Tags custom-post-types, post-meta

How to stop WordPress from updating the post meta

How to stop WordPress from updating the post meta Prior to updating meta data, WordPress fires the filter “update_{$meta_type}_metadata”. This is a dynamic filter that depends upon the post type that the meta data is attached to. For instance, the update_post_metadata will fire prior to the updating of a post post_type. Likewise, update_page_metadata will fire … Read more

Categories hooks Tags hooks, post-meta

Display current user’s custom post meta in sidebar

The follow source is more formatted, but in the goal the same like your tests. You should see, the first line to get the ID is not necessary. You have the ID of the user, there is present. If the loop get posts, it print a title and the date. Important is, that the post … Read more

Categories post-meta Tags post-meta, users

Get custom fields without _edit_last, _edit_lock, _wp_page_template and _visual-subtitle

You should replace your call to get_post_custom with get_post_meta. get_post_custom retrieves all the post meta fields whereas with get_post_meta you can specify the key of the meta field you want. $meta = get_post_meta( $level_2->ID, ‘Body Repair’ ); This would give you an array with the value for the Body Repair meta key, To return a … Read more

Categories custom-field Tags custom-field, post-meta

count post meta values

Thank You @prosti for your answer I made Thise small code based on your answer and it works for me global $post; $query_args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘order’ => ‘DESC’, ‘posts_per_page’ => -1, ‘cat’ => 1, // ‘fields’ => ‘SUM(amount_to_paid)’, ); $sum = 0; $query = new WP_Query($query_args); if ( $query->have_posts() … Read more

Categories post-meta Tags count, post-meta

Custom permalink for each post

Migrating content from Drupal to WordPress is bit tricky task and requires expertise. If you are familiar with WordPress development, try to find some solution around “save_posts” hook which will get triggered whenever new post/page gets saved into database. Before you jump into actual coding, I suggest you to take a look at these articles, … Read more

Categories posts Tags guids, permalinks, post-meta, posts

Need a SQL query to update meta_key=’_price’ with value in meta_key=’_regular_price’

The reason your query doesn’t return anything fruitful is because you’re not comparing the meta_value of both of the meta_keys, you’re comparing non-numeric outcomes of meta_key = ‘x’ and meta_key = ‘y’. SELECT post_id, post_title FROM wp_posts INNER JOIN wp_postmeta ON post_id = post_id WHERE post_type=”product” AND meta_key=’_regular_price’ > meta_key=’_price’ What you want to be … Read more

Categories post-meta Tags post-meta, sql, woocommerce-offtopic

Link image with data from the wpdb

Do you need to query only the items that has banner_link value set to https://www.mypage.com ? If no, you can remove the meta_query part from your query. <?php // function to show home page banner using query of banner post type function wptutsplus_home_page_banner() { // start by setting up the query $get_banner = new WP_Query( … Read more

Categories Database Tags database, post-meta

How to delete duplicate records in wp_postmeta database table?

You don’t need a select statement to do this, a DELETE statement can handle finding the records. Make sure to backup your database first, then try the following SQL query. DELETE FROM wp_postmeta WHERE meta_key = ‘cb_full_width_post’ AND meta_value != ‘nosidebar-narrow’

Categories post-meta Tags duplicates, mysql, post-meta
Older posts
Newer posts
← Previous Page1 … Page94 Page95 Page96 … Page204 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
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 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