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

Move Title and the Content WYSIWYG editor position

There is a way to put that meta box after the title. There is a hook called edit_form_after_title. If you look at the source there is no hook earlier than that that isn’t much too early– outside of the <form tag. The following does move that box to the location after the title… function generic_box() … Read more

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

Publish and save specific postmeta to a filtered post_type

Do the check inside the callback. save_post will pass you both the post ID and the post object: do_action(‘save_post’, $post_ID, $post); So… function save_my_meta_box_to_postmeta($post_ID, $post) { if (‘yourtype’ === $post->post_type) { echo ‘<pre>’; var_dump($post_ID,$post); echo ‘</pre>’; die; } } add_action(‘save_post’,’save_my_meta_box_to_postmeta’,1,2); You may want other conditionals as well like !DOING_AJAX, for example.

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

Unfiltered html with update_post_meta

Do you really want your members to be able to insert unfiltered html in the database? By default, it’s not allowed as a security measure to protect your installation. You could allow it by adjusting kses filters. Or by-pass the filters via a custom sql query.

Categories post-meta Tags buddypress, post-meta

mass delete posts based on metadata

from my comment above: I can do this now with two separate queries, but it would be nice to be able to do it in one. Still, this is progress. The first query is like this: DELETE wp FROM wp_posts wp LEFT JOIN wp_postmeta pm ON pm.post_id = wp.ID WHERE pm.meta_key = ‘state’ AND pm.meta_value … Read more

Categories post-meta Tags post-meta, sql

How to display sql query fired by posts_where

The quick and dirty way is to put var_dump($wp_query->request) (or whatever you’ve named the WP_Query object if you’ve created a new one) on the page the query runs on and after it runs. You can also add define(‘SAVEQUERIES’, true); to wp-config.php to save the queries for analysis. You can read the queries something like this … Read more

Categories post-meta Tags post-meta

How do I insert a new meta key / value pair, but only if another meta key is present?

There’s no need to do this via raw SQL. Make use of the WordPress core functions get_post_meta and update_post_meta. Use them like so: $existing = get_post_meta( $post_id, ‘existingkey’, true ); if ( ! empty( $existing ) ) { update_post_meta( $post_id, ‘newkey’, ‘newvalue’ ); } Done.

Categories post-meta Tags post-meta, sql

add unique string as custom-field to every post

There is a simplier way to do what you want to: function add_unique_post_identifier( $post_id ) { $unique_post_identifier = get_post_meta($post_id, ‘unique_post_identifier’, true); // do nothing if post type is not ‘post’ or identifier is already set if (‘post’ != get_post_type( ( $post_id ) ) || !empty($unique_post_identifier) ) return; $generated_id = uniqid(); update_post_meta($post_id, ‘unique_post_identifier’, $generated_id); } // … Read more

Categories post-meta Tags post-meta

How to get specific post meta by title or id

get_field is a replacement for get_post_meta you have to use only it: $my_post_meta = get_field(‘album_image’, 556); if ( ! empty($my_post_meta) ) { // use the image } If you don’t know the ID and want retrieve the post meta via post name, you have to use WP_Query or get_posts to ge the post via slug: … Read more

Categories custom-post-types Tags custom-field, custom-post-types, post-meta, wp-query

Remove last character in get_post_meta

This is more of a PHP question then a WordPress question. If you want to remove punctuation marks like (.,-;:) you can try this recursive version: $s = get_post_meta( $post->ID, ‘one_line_summary’, TRUE ); if( function_exists( ‘remove_punctuation_marks’ ) ) $s = remove_punctuation_marks( $s ); with /** * Remove punctuation marks (.,-;:) if they’re the last characters … Read more

Categories post-meta Tags post-meta

get meta value from database by post id

Use the third parameter of the get_post_meta(). If the third parameter is set to true then the function will return a single result, as a string. If false, or not set, then the function returns an array of the custom fields for example:– $froms = get_post_meta( 139, ‘from’, true ); $tos = get_post_meta( 139, ‘to’, … Read more

Categories plugins Tags plugins, post-meta
Older posts
Newer posts
← Previous Page1 … Page107 Page108 Page109 … 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