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

custom-post-types

Single custom post type page redirecting to 404 page

Newly registered CPT shows 404 because, the register_post_type() doesn’t flush the rewrite rules. So it’s up to you, whether you want to do it manually or automatically. Manually: Get to /wp-admin/, then Settings » Permalinks, and then just hit the Save Changes button to flush the rewrite rules. Automatically: You can flush the rewrite rules … Read more

Categories custom-post-types Tags 404-error, custom-post-types, single

How to add meta box to backend menu page

Here is an example metabox that displays at the very top of the left hand side in the nav menus interface: /** * Instantiates the class */ add_action( ‘admin_init’, array( ‘call_someClass’, ‘init’ ) ); /** * The Class */ class call_someClass { const LANG = ‘exch_lang’; public static function init() { $class = __CLASS__; new … Read more

Categories custom-post-types Tags archives, custom-post-types, menus, metabox

clients list using wordpress

You’ll want to use a custom post type for this. But don’t let the terms “custom post type” scare you off. For example, one of my clients needed to present a “line card” displaying their various partners. All they wanted, originally, was the name and logo of their various partners. After I built out the … Read more

Categories custom-post-types Tags custom-field, custom-post-types, custom-taxonomy, functions

Custom Post Type, WP_Query and ‘orderby’

As far as I can tell, there is no work-around to this at the database level. This is a problem I run into somewhat often, which is the case you need to turn an list with structure references into an an ordered array with children elements appearing immediately after their parents. This can be accomplished … Read more

Categories custom-post-types Tags custom-post-types, multisite, sort, wp-query

Add custom post type items from frontend

If you are willing to pay for it, the Gravity Forms plugin allows you to create forms that map to your Custom Post Types (even regular post and page – types) as well as map to your custom fields. For those who aren’t and who are willing to roll up their sleeves then you can … Read more

Categories custom-post-types Tags custom-post-types, front-end, wp-query

How to intercept publish post for a custom post type “event”

Read the codex, that’s where i finally found the answer : https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post in the end : Custom Post Types To trigger this action for a custom post type, use publish_{$custom_post_type}. e.g. if your post type is ‘book’ use: add_action( ‘publish_book’, ‘post_published_notification’, 10, 2 );

Categories custom-post-types Tags actions, custom-post-types

How to put custom post types on front page

So if you’ve registered a CPT called wpse_242473_custom_post_type you can use this to put 6 recent posts of that type onto your static front page (or anywhere). You can use a shortcode or a template tag and the function should work for both. It’s a modification of some code I use in a lot of … Read more

Categories custom-post-types Tags custom-post-types, frontpage, pre-get-posts, theme-development, wp-query

How to list custom taxonomy categories?

To get a list of your custom taxonomies, you can use the get_terms() function to create a loop: // Get the taxonomy’s terms $terms = get_terms( array( ‘taxonomy’ => ‘your-taxonomy’, ‘hide_empty’ => false, ) ); // Check if any term exists if ( ! empty( $terms ) && is_array( $terms ) ) { // Run … Read more

Categories custom-post-types Tags custom-post-types, custom-taxonomy, taxonomy

Many to Many Relationship between Two Custom Post Types

As Milo noted, there is no built in way to do a many to many relationship between two custom post types. That being said, these days it isn’t too hard to do it yourself without a plugin if wanted. I do many to many relationships between custom post types by using non-singular post meta. e.g. … Read more

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

How can I add a column/s to wp_posts table?

You can technically add a post column with SQL but I’d caution against it as backup scripts, exports etc. would likely ignore it. Instead, I would add the content as a post_meta, either using a Custom Field or through PHP with the update_post_meta() function. To fetch a post based on the meta simply use: $args … Read more

Categories custom-post-types Tags custom-field, custom-post-types, metabox, posts
Older posts
Newer posts
← Previous Page1 … Page980 Page981 Page982 … Page1,037 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