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

If metabox has content display content

You have to list the keys of the meta fields saved in the metabox, because their is no function to dynamically retrieve all the fields saved in specific metabox. For example: $store_openingtimes_keys = array( ‘_cmb_open_monday’, ‘_cmb_open_tuesday’, ‘_cmb_open_wednesday’, ‘_cmb_open_thursday’, ‘_cmb_open_friday’, ‘_cmb_open_saturday’, ‘_cmb_open_sunday’ ); // all the not empty meta for the post $meta = array_filter( get_post_custom($post->ID) … Read more

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

WooCommerce custom taxonomy as meta?

As you can’t use »product attributes« and have two additional »custom taxonomies« just use get_the_term_list() to achieve what you want. The basic usage would be to place below code where you want to show the additional output – take a look at the codex page for information about formatting options. Code: //Show list of post … Read more

Categories custom-taxonomy Tags custom-taxonomy, plugins, post-meta

wordpress update multiple posts post meta

This is because there is no relationship between the item id and the price when you are collecting the posted data. Do the changes as below. Change the sale_price to below to include the item id <input name=”sale_price[<?php echo get_the_id(); ?>]” type=”text” value=”<?php echo get_post_meta(get_the_id(), “_sale_price”, true); ?>” /> Then change the loop for collecting … Read more

Categories post-meta Tags post-meta

WordPress postmeta: Store data as an array or single item?

Unless you are building a heavy web application, with billions of rows ( and maybe even then ), the number of rows for MySQL is not an issue. Saving your data in an array will make calling the data simpler (just one call), and keep the database smaller, but it will make parsing and searching … Read more

Categories post-meta Tags post-meta

Meta box values are displayed on Custom Fields list. Is it possible to hide them?

Prefix all meta data keys used in meta boxes with an underscore, this will hide them automatically from the built in Custom Fields interface. So instead of: themeprefix_source Use: _themeprefix_source

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

query_posts orderby postmeta [closed]

For numeric data, the orderby key should have value as meta_value_num. Use WP_Query and change ‘orderby’ => ‘meta_value’ to ‘orderby’ => ‘meta_value_num’

Categories query-posts Tags post-meta, query-posts

get_post_meta inside echo [closed]

Use it like this <?php if ( in_category( ‘951’ )) { echo ‘Online. Todas las provincias’; } else { global $wp_query; $postid = $wp_query->post->ID; $meta = get_post_meta($postid, ‘provinciadestacada’, true); echo $meta; } ?> To do it in reverse as you want: global $wp_query; $postid = $wp_query->post->ID; $meta = get_post_meta($postid, ‘provinciadestacada’, true); if(!empty($meta)) { echo $meta; … Read more

Categories post-meta Tags post-meta

Front end file upload returning wrong attachment url

For wp_insert_attachment and wp_generate_attachment_metadata, change $file_name in the following way. $file_name = $upload_dir[‘path’] . “https://wordpress.stackexchange.com/” . basename($file_name); WordPress codex for both function ( here and here ) says- ‘ Use absolute path and not the URI of the file. The file MUST be on the uploads directory’ $_FILES[‘fileUpload’] just gives the name of the file … Read more

Categories PHP Tags attachments, forms, php, post-meta, uploads

How can I get some of a posts meta data whilst it is still inserting?

Maybe you can move all the logic to added_post_meta & ‘updated_postmeta’ hooks. add_action( ‘added_post_meta’, ‘update_carnews_adverts_aprent’, 10, 4 ); add_action( ‘updated_postmeta’, ‘update_carnews_adverts_aprent’, 10, 4 ); function( $meta_id, $object_id, $meta_key, $meta_value ) { if ( $meta_key !== ‘_wpcf_belongs_carnews_id’ || ! is_numeric($meta_value) ) return; $post = get_post( $object_id ); if ( $post instanceof WP_Post && $post->post_type == ‘carnews-adverts’ … Read more

Categories custom-post-types Tags actions, custom-post-types, post-meta, wp-insert-post

Sanitaizing Select Optin For Custom Post Type Metabox in WP

You should scape data when displaying it, not when saving. To sanitize, I think the best choice in this case is sanitize_text_field() if( isset( $_POST[‘my_meta_box_select’] ) ) { update_post_meta( $post_id, ‘my_meta_box_select’, sanitize_text_field( $_POST[‘my_meta_box_select’] ) ); } Then, only if you are going use the data as attribute you should use esc_attr(): $selected = isset( $values[‘my_meta_box_select’] … Read more

Categories custom-post-types Tags custom-post-types, metabox, post-meta, sanitization
Older posts
Newer posts
← Previous Page1 … Page84 Page85 Page86 … 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