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_meta remains empty while looping all menu items and using the ID

You are sending the ID of the menu item not the ID of the page try using url_to_postid() like this: <?php $array_menu = wp_get_nav_menu_items(‘header-menu’); $menu = array(); foreach ($array_menu as $m) { if (empty($m->menu_item_parent)) { ?> <h4><a href=”https://wordpress.stackexchange.com/questions/257249/<?php echo $m->url;?>”><?php echo $m->title;?></a></h4> <p> <?php global $wp_query; $pageID = url_to_postid( $m->url ); echo get_post_meta($pageID, ‘meta_box_subtitle’, true); … Read more

Categories post-meta Tags post-meta

How to show author name only if the post is in a specific category?

Yes, that is the line you need to edit, and you need to check and see if the current post is within your specified category. So you could replace that line with this code and it should do the trick: if(in_category(90)) { $author = mom_option(‘post_meta-author’) == 1 ? ‘<span class=”author vcard” itemprop=”author” itemscope itemtype=”https://schema.org/Person”>’.__(‘Posted By:’, … Read more

Categories categories Tags author, categories, post-meta

How can I get my iFrame to work with url from post_meta?

Almost every time when I post a question, I’m able to find the solution on the internet.. Sorry guys and girls for the spam! Solution <div class=”featured-img-blog”> <?php global $wp_embed; $get_video_url = get_post_meta(get_the_ID(), ‘video_url’, true); echo “<p align=center>” . $wp_embed->run_shortcode(”) . “</p>”; ?> </div>

Categories post-meta Tags iframe, post-meta

How add post_meta from user_meta?

Yo might need the user meta for this https://codex.wordpress.org/Function_Reference/get_user_meta You can get to it by including the post author as the user_id. So: get_user_meta($post->post_author, ‘meta_key’

Categories post-meta Tags post-meta

How to generate numbers indistinguishable for the IDs of the posts

The post ID must be a number, it can’t an alphanumeric string. The simplest way to force the use of the high numbers for ID’s is to use phpMyAdmin, or some similar database management system, and edit the wp_posts table. With phpMyAdmin: Open phpMyAdmin, open wp_posts table, and open Operations tab. Find AUTO_INCREMENT field, and … Read more

Categories posts Tags actions, filters, post-meta, posts

get_post_meta pagination

On a singular view, the current page number can be accessed with get_query_var(‘page’). You need to subtract 1 to get the corresponding array value. Note that the first page will redirect to the URL without page number, this is just a thing WordPress does. // get meta $metas = get_post_meta( $post->ID, ‘your_meta_key’, false ); // … Read more

Categories post-meta Tags post-meta

Display post metadata: “title, category, author, date” with shortcode

If you are outside the loop then you can use to get them by post id, you can play around with these snippet: shortcode for author’s name: function author_name_shortcode(){ global $post; $post_id = $post->ID; $author = get_the_author($post_id); return $author; } add_shortcode(‘post_author’,’author_name_shortcode’); shortcode for categories name: function category_name_shortcode(){ global $post; $post_id = $post->ID; $catName = “”; … Read more

Categories shortcode Tags post-meta, shortcode

How to check if Woocommerce Order number equals to post ID?

global $post; $order = wc_get_order($post->ID); if(!empty($order) && $post->ID == $order->get_id()){ //do things } This should work. The first check is because the order with the post ID does not have to exists just as you said.

Categories plugin-development Tags plugin-development, post-meta, woocommerce-offtopic

Does “update_post_meta” check if value is the same before updating?

update_post_meta() uses update_metadata() to update the post metadata, and if you call update_post_meta() without specifying the fourth parameter (i.e. $prev_value) — or that the value is empty, then yes, update_metadata() will check if the new value is the same as the current value in the database, and if so, the metadata will not be updated. … Read more

Categories post-meta Tags post-meta

Saving html into postmeta without stripping tags – safe?

HTML is perfectly safe in the database. As long as you’re using update_post_meta() or add_post_meta(), and not SQL directly, WordPress will make sure that you’re safe from any SQL issues. The real trouble with allowing HTML in meta is that if you are outputting this HTML on the front-end without escaping, then any user that … Read more

Categories post-meta Tags html, post-meta
Older posts
Newer posts
← Previous Page1 … Page154 Page155 Page156 … 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