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

replacing the_autor or make callback

There is no need to change the the_author() function itself. A simple conditional tag will do the trick. Example: <?php /*** on your functions.php file ***/ function ifRegistered() { if(is_user_logged_in()) { the_author(); } else { echo get_the_post_meta($post->ID, ‘your_post_meta_key’, true); // or anything else, of course } } /*** on the template you want to use … Read more

Categories post-meta Tags loop, post-meta

Widget: Custom Post Type Post Listing Dropdown on Admin Side

Here is what I discovered and use, maybe it will help you: function custom_posttype_dropdown($name, $selected) { $out = “”; $posts = get_posts( array( ‘post_type’ => ‘bctap_templates’, ‘numberposts’ => -1 ) ); if($posts ) { $out=”<select name=””.$name.'” ><option>Select a Template</option>’; foreach( $posts as $p ) { if ($p==$selected) { $selected = “selected = ‘selected'”; } else … Read more

Categories custom-post-types Tags custom-post-types, dropdown, post-meta, select, widgets

Deleting Custom Posts & Meta Data on Uninstall

I just came across this in a search and thought I’d reply just in case you didn’t figure this out. I’m not 100% sure the best way to go about this but I can provide some information that may be helpful. $wpdb has both prefix and base_prefix members, so you can get the ‘wp_4_’ by … Read more

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

Retrieving multiple values to the Post Meta (using an array)

Aha! I think I found your answer. Two facts: The description of the $meta_value argument on add_post_meta() functions’s codex page notes: An array will be serialized into a string. The $single argument’s description on the get_post_meta() function’s codex page notes: If set to true then the function will return a single result, as a string. … Read more

Categories array Tags array, post-meta

Add a Save Button to Custom Meta Box [duplicate]

To update a post. <input id=”publish” class=”button-primary” type=”submit” value=”Update” accesskey=”p” tabindex=”5″ name=”save”>

Categories plugin-development Tags metabox, plugin-development, post-meta

order posts by meta value on posts page

So I figured out how to get what I want, but it’s still not perfect. The problem revolved around how my custom meta value was being stored – basically as a string. I needed to tell MySQL that it was a date, so it could be used to order the posts. To this end, I … Read more

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

Generate multiple goo.gl shortlinks for qtranslate bilingual blog

So I’ve managed to solve this. The googl_shortlink function from above now looks like this: function googl_shortlink($url, $post_id = false) { global $post; if (!$post_id && $post) $post_id = $post->ID; elseif ($post_id) $post = get_post($post_id); // list all the active languages in an array $enabled_languages = get_option(‘qtranslate_enabled_languages’); if (is_404()) return; if ($post && $post->post_status != … Read more

Categories post-meta Tags multi-language, plugin-qtranslate, post-meta

If meta key exists in get posts function otherwise create it

This “not exists” functionality isn’t possible using a regular meta query. It’s being worked on, but it looks like it’s been shuffled to a future release (see this trac ticket for more insight). In the meantime, you have to run a custom SQL statement using $wpdb, as in DeadMedic’s answer that Milo linked to in … Read more

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

Saving value of a selection option in comment form as comment meta

You can use the function update_user_meta for logged in users and the php function setcookie for the visitors. Here is a start how to work with update_user_meta You can run this function on submission of the form or by running it by AJAX, i would recommend you to run it with AJAX. function wpse_update_user_commentform() { … Read more

Categories plugin-development Tags comment-form, custom-field, plugin-development, post-meta

running function during post save and adding variable to post meta

Yes, most definitely. Take this skeleton code below as a base for a function that would do what you want, and place it in your functions.php: function your_vimeo_meta_function ($post_id) { // some verifications first if ( $post_id == null || empty($_POST) ) return; if ( !isset( $_POST[‘post_type’] ) || $_POST[‘post_type’]!=’post’ ) return; if ( wp_is_post_revision( … Read more

Categories post-meta Tags post-meta
Older posts
Newer posts
← Previous Page1 … Page140 Page141 Page142 … 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