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 category as a separate string and url

First you have to find the category ID, which can be done easily with the function get_the_category(). To get the slug, use: $catID = get_the_category(); $catSlug = $catID->slug. To get the link: $catLink = get_category_link($catID).

Categories posts Tags categories, loop, post-meta, posts

update_post_meta not working?

I’m not quite sure about what you want to do… Maybe it’s this: add_action(‘save_post’, ‘update_thumb’); function update_thumb($post_id) { //verify post is not a revision if (! wp_is_post_revision($post_id)) { $new_value=”testxxx”; update_post_meta($post_id, ‘thumb’, $new_value); } }

Categories post-meta Tags post-meta

New Table vs Post / Comment Meta

You can use both: Comment meta for the plain vote count, because that is easy to fetch with a standard query. A custom table storing additional data to prevent vote fraud and other issues. These tables might be used for rare events (voting) only, but they are not used to list comments in the back-end … Read more

Categories post-meta Tags post-meta

Modify custom field from front end

I assume that you want to update custom field. You can use: global $post; update_post_meta($post->ID, $meta_key, $meta_value); http://codex.wordpress.org/Function_Reference/update_post_meta

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

Conditional For get_the_author_meta

get_the_author_meta() returns the data for use in PHP. To display the information instead, use the_author_meta() http://codex.wordpress.org/Function_Reference/get_the_author_meta Your code does not echo data even if it is present. Add an echo or use the_author_meta <?php if(get_the_author_meta(‘twitter’) ): ?> <a href=”https://www.twitter.com/<?php echo get_the_author_meta(‘twitter’); ?>” target=”_blank”>Twitter</a></p> <?php else: ?> <strong>No website</strong> <?php endif; ?>

Categories post-meta Tags author, post-meta

Random element in get_post_meta array

As the content of the meta data is actually a string (according to your comment), your code won’t work. get_post_meta(), respectively get_metadata() will only deserialize the content if it’s actually serialized. So, if you can’t change how the data is saved, ie make sure that an actual array or already serialized content is passed to … Read more

Categories array Tags array, post-meta

updating one custom meta field only

It sounds like you are trying to directly save the altered information to the serialized value in the database. You can’t do that. You have to extract the current meta data for that key so that you have and array or object, update that array or object, and then save the whole thing back to … Read more

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

Array of user ids to list of user names

get_userdata() – http://codex.wordpress.org/Function_Reference/get_userdata – returns an object. You need to provide the correct return value: echo $name->nicename;

Categories post-meta Tags array, post-meta, user-meta

get_post_meta in one post only

You need to put an exception into your conditional: if(get_post_meta($post->ID, ‘label’, true) != ”){ $label = get_post_meta($post->ID, ‘label’, true); $label=”<em>”.$label.'</em>’; } else { $label=””: }

Categories post-meta Tags post-meta

Post meta select input, if statement

I can’t test this but it looks like something like what you have should work: if (‘option1’ == get_post_meta($post->ID, ‘item_one’, true)) { //do something } elseif (‘option2’ == get_post_meta($post->ID, ‘item_one’, true)) { //do something else } else { //do something else } You didn’t need all those opening and closing tags, and some of them … Read more

Categories PHP Tags metabox, php, post-meta
Older posts
Newer posts
← Previous Page1 … Page81 Page82 Page83 … 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