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

publish_post action hook doesn’t give post_meta_data

If the wp_send_json() function is sending the right data, but for some reason you want to use another function to actually send the JSON data, then you can use wp_json_encode(). This is basically the only thing that wp_send_json() does before sending off the data. add_action( ‘publish_post’, ‘wpse_228607_publish_post’, 10, 2 ); function wpse_228607_publish_post( $post_id, $post ){ … Read more

Categories post-meta Tags post-meta

get_post_meta returning empty string when data shows in the database

Edit Invalid Answer The answer below is invalid as get_the_id() and get_the_ID() both return the required ID of the post inside the Loop. Thanks to @Jess_Pinkman for pointing it out. Your code should be working fine, but the only issue is you are using an incorrect function to get the ID of the post inside … Read more

Categories post-meta Tags post-meta

Allow user to create instances of custom field

you can make repeating fields with the WP alchemy class http://www.farinspace.com/wpalchemy-metabox/#have_fields_and_multi

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

Update all posts automatically when using post_meta

Probably your already solved this (hopefully not by hand). This part of your question is intriguing: I found that if I open a post through WordPress front-end and then click “update” the custom field data and the post content “sync” Do you mean back-end, right? If so, I think a bulk update would solve this … Read more

Categories posts Tags custom-field, php, post-meta, posts, shortcode

Get ID of a page containing secondary loop in content

As others figured already out: If you have third party plugins with custom queries, you’ll have a bad day! One solution might be caching your results. Template (e.g.: page.php) while (have_posts()): the_post(); global $my_cached_data; $post_id = get_the_ID(); /* * If you have single meta keys, this array_map function * makes them easy to access; otherwise … Read more

Categories loop Tags content, loop, post-meta

Gutenberg how to make attribute to save to meta

The meta value is read when the block loads and assigned to the block attribute. Changes to the block will update the attribute and when the post saves the value will save to the meta. So, as far as I understood, there is no need to actually save anything in the registerBlockType js function. The … Read more

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

Custom Queries: Joining On Meta Values From Two Custom Post Types

So based on our discussion, the meta named opposition (for match posts) has its value set to the slug of the corresponding club post; e.g. club-1, club-two, etc., right? If so, then you first get the ID of the club post using a custom query (see in the code below) and then you can access … Read more

Categories custom-post-types Tags custom-post-types, join-tables, meta-query, post-meta, query

How to use Post Custom Metadata in Post Titles and Post Permalinks

This will do. The slug is saved on the wp_posts while custom fields are on the wp_posts_meta. If you want to make it like that you can use an action hook on save_post that will get the value of the custom fields and saves it as the post slug. Here is the code add_action(‘save_post’, ‘set_slug’); … Read more

Categories url-rewriting Tags post-meta, rewrite-rules, url-rewriting

Storing meta fields multiple times OR once with multi dimensional array?

I figured I’ll leave the meta values saving on multiple fields in the db, because I’ve been doing allot of pre_get_post query filtering. Some of the features in there are for searching/filtering on post meta data and would it start making things very difficult if I was to start saving values into doubly serialized values. … Read more

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

Restrict post edit/delete based on user ID and custom field

Through a lot more research and some trial and error, I figured out the correct code to use that will restrict a post from being edited based on the user ID AND a custom meta field. $user = get_current_user_id(); $super_users = array(1); The first two pieces of code within the function are important for restricting … Read more

Categories post-meta Tags actions, content-restriction, post-meta
Older posts
Newer posts
← Previous Page1 … Page191 Page192 Page193 … 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