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

Show the same Article Available in Other Categories

First you have to create secondary loop and use it. // $categories = wp_get_post_categories($post->ID); $categories = get_the_category($post->ID); foreach ( $categories as $category ) { echo $category->name; } Description get_the_category( $post->ID ); This tag may be used outside The Loop by passing a post id as the parameter. Note: This function only returns results from the … Read more

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

Next and Previous loop

Use get_adjacent_post to first see if there’s actually a next post: if (get_adjacent_post (false, ”, false)) { next_post_link (‘%link’, ‘Next Project >’, true, ”, ‘projectcategory’); } else { // manually create link to first post here } This site shows one way of actually getting the first post’s link, such as with a WP_Query call … Read more

Categories loop Tags loop, next, post-meta, previous

Display custom post type from dynamic custom field

Try changing $meta[‘title’] to $meta[‘title’][0] & the same thing for $meta[‘track’] . change it to $meta[‘track’][0] UPDATE: I looked at the code more deeply and you basically need a foreach loop. Here’s the final code should look like: <?php $args = array( ‘post_type’ => ‘page’ ); $repeat_loop = new WP_Query( $args ); if ( $repeat_loop->have_posts() … Read more

Categories custom-post-types Tags custom-post-types, post-meta, query-posts, wp-query

Header: Include Date Published and Date Modified

You can check if is_singular page/post and then use global $post to get the post ID outside the loop. Also for the modified date you should use get_the_modified_date instead because you’re already echoing. <?php if(is_singular()): ?> <?php global $post; ?> <meta name=”date” content=”<?php echo get_the_date( ‘m-d-Y’, $post->ID ); ?>”> <meta name=”revised” content=”<?php echo get_the_modified_date( ‘m-d-Y’, … Read more

Categories headers Tags date, headers, post-meta

Insert post metadata for all posts in CPT at once if metadata no existent

To anyone interested this is the query that worked for me: INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value) SELECT p.ID, ‘score’ AS meta_key, 0 AS meta_value FROM $wpdb->posts AS p WHERE p.post_type=”my_cpt” AND p.ID NOT IN ( SELECT p2.ID FROM $wpdb->posts AS p2 INNER JOIN $wpdb->postmeta AS pm ON pm.post_id = p2.ID WHERE pm.meta_key = ‘score’ ) But … Read more

Categories custom-post-types Tags custom-post-types, mysql, post-meta, wpdb

How to wrap meta values seperated by comma in ? [closed]

If you are storing your meta values as a single string separated by commas, you can use the native PHP explode() to store them in an array: $ct = get_post_meta($post->ID, ‘ct’, true); // Store them in an array $country_array = explode(‘,’ , $ct); // Run a loop and echo them foreach( $country_array as $key => … Read more

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

Converting a dynamic piece of code using WordPress Loop into a static one using Post ID

Converting a dynamic piece of code into a static one is a pretty straight forward task. It’s the other way that is complex. Any WordPress function that can accept get_the_ID(), can also accept a string as an ID. Some even accept arrays. So, simply turning get_post_meta(get_the_ID(), ‘t_puck_imvi’, true); to get_post_meta( 123 , ‘t_puck_imvi’, true); Will … Read more

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

Ordering posts in Search & taxonomy by post_meta

You have a couple of issues with the code you are trying. To check the query is for your CPT archive: You are using $query->is_post_type() but it doesn’t work (as far as I know, its not even a function). Instead you can use either: if (is_post_type_archive(‘business’)) {…} or (if its not only on the archive … Read more

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

Storing data for a wordpress plugin

Using a taxonomy is probably the best way. Creating a CPT will be the second option. The problem with CPTs is that you will need to store data in the mesta table which will most likely have some performance impact on other things being done on the site. Taxonomy term meta data is less bloated … Read more

Categories Database Tags database, post-meta

Set the value of custom field when post is published or updated

It looks to me like save_post doesn’t work the way you currently have your add_action. According to the Codex, you need to run your function on save_post and check the post type in the function. function get_film_data( $post_id ) { if ( get_post_type($post_id) == ‘film’ ) { // If this is just a revision, don’t … Read more

Categories save-post Tags post-meta, save-post
Older posts
Newer posts
← Previous Page1 … Page146 Page147 Page148 … 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