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

Meta keywords and descriptions plugin for manually editing meta for each page/post

the simple solution would be to paste this snippet of code in your theme’s functions.php file : add_action(‘wp_head’,’keywords_and_desc’); function keywords_and_desc(){ global $post; if (is_single()||is_page()){ if(get_post_meta($post->ID,’my_keywords’,true) != ”) echo ‘<meta content=”‘.get_post_meta($post->ID,’my_keywords’,true).'” name=”keywords”>’; if(get_post_meta($post->ID,’my_description’,true) != ”) echo ‘<meta content=”‘.get_post_meta($post->ID,’my_description’,true).'” name=”description”>’; } } And the just add keywords and description using the built in custom fields on a … Read more

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

How to set author for post AND post attachments

Use this in your theme’s functions.php: add_filter( ‘add_attachment’, ‘wpse_55801_attachment_author’ ); function wpse_55801_attachment_author( $attachment_ID ) { $attach = get_post( $attachment_ID ); $parent = get_post( $attach->post_parent ); $the_post = array(); $the_post[‘ID’] = $attachment_ID; $the_post[‘post_author’] = $parent->post_author; wp_update_post( $the_post ); }

Categories attachments Tags attachments, author, post-meta

Change slug with custom field

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’); function set_slug($post_id){ $new_slug … Read more

Categories posts Tags permalinks, php, post-meta, posts, slug

Adding an assisting editor box to Post page

add_meta_box should give you the box container like your have pictured. You have a select drop-down because that is what you created here: echo ‘<select name=”rating”>’; echo ‘<option value=””‘ . ((($value == ”) || !isset($ratings[$value])) ? ‘ selected=”selected”‘ : ”) . ‘> Untouched </option>’; // output each rating as an option foreach ($ratings as $id … Read more

Categories post-meta Tags metabox, post-meta

Add a meta description to home page?

You do not need to add Yoast if you only want to add meta tags to the homepage. Just some minor editing will save you on performance. You can use the is_home() function. Insert this to your header.php: <?php if (is_home()) { ?> <meta name=”description” content=”Your description for homepage…” /> <?php } else { ?> … Read more

Categories metabox Tags homepage, metabox, plugin-wp-seo-yoast, post-meta

wp_insert_post() getting slower the more posts

I found the solution by the comment from birgire what tells to use wp_defer_term_counting() as follows: if( ! $errors ) { // Set wp_defer_comment_counting(); wp_defer_term_counting( true ); foreach( $lines as $line ) { // Import post $args = array( ‘post_title’ => $new_vipost_title, ‘post_content’ => $new_vipost_content, ‘post_status’ => ‘publish’, ‘post_type’ => $vipost_type, ); $post_id = wp_insert_post( … Read more

Categories wp-insert-post Tags post-meta, wp-insert-post

Update Multiple Post Meta for the Same Post In One call?

EDIT: Original answer was inaccurate as you can do this with wp_update_post and the meta_input field As per the updated question and comments this is possible with wp_update_post (or wp_insert_post for a new record) using the meta_input key on the array, e.g.: $metaValues = array( ‘key1’ => ‘value1’, ‘key2’ => ‘value2’, // … as many … Read more

Categories plugins Tags php, plugin-development, plugins, post-meta, theme-development

How to get all term meta for a taxonomy – getting term_meta for taxonomy

You’re using $term->ID. Taxonomy terms do not have an ID property. They have a term_id property: $display_type = get_term_meta( $term->term_id ); You’ll notice that WooCommerce is using this, while your attempts are not.

Categories post-meta Tags meta-value, post-meta, terms, wpdb

How to update/delete array in post meta value?

To update post meta that are an array: you have to fetch the original values, change the value you need and update it again. For example $list_of_values = get_post_meta($post_id, ‘_list_values’, true); if(!empty($list_of_values)) { $list_of_values[“some_prop”] = “new value”; } update_post_meta($post_id, ‘_list_values’, $list_of_values);

Categories post-meta Tags post-meta

Is there a hook / action that is triggered when adding or removing a post thumbnail?

I think you want to use the added_post_meta hook instead of updated_post_meta because you’re not updating the meta here, only adding it. At least in the case of the _thumbnail_id, where we must delete it before adding it again (no update) through the admin UI. Investigating this further we see that this part of the … Read more

Categories custom-field Tags custom-field, featured-post, post-meta, post-thumbnails
Older posts
Newer posts
← Previous Page1 … Page188 Page189 Page190 … 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