Meta_Query as a way how to setup CPT permalinks – is it a good thing?

Since it is a performance question, you might be able to avoid using meta keys at all by storing/getting that data another way and not having to set a separate meta field to match with… a. You could get the year from the published $post->post_date… So that when doing the query just use the date … Read more

Can’t get post id on page that is a custom post type archive

EDIT I get the idea that I might have misread your question Just a few notes here If archive-projects.php is a page template, rename it. You should not use archive as a prefix for a page template, or for that matter any other reserved template name. Page templates should be named page-{$name}.php or any other … Read more

Custom post type yearly/ monthly archive permalinks

Here’s an example using add_rewrite_rule to handle years and months for a custom post type where news is the slug. Visit the Settings > Permalinks page in admin to flush rewrite rules after this is added. You could also put this in a plugin and flush rewrite rules on plugin activation. function wpa83797_news_rewrite_rules(){ add_rewrite_rule( ‘news/([0-9]{4})/([0-9]{1,2})/?$’, … Read more

Page Template as Custom Post Type Archive

Since WordPress version 4.4 the hook ‘theme_page_templates’ allows to set arbitrary page templates. It means that it’s possible to show arbitrary values in the “Page Template” menu of the page edit screen, and when selected, the value will be stored in the page template meta for the page. This means that you can “automagically” create … Read more

How to set a custom post type to have viewable future posts

I’ve been able to solve this myself. My entire code for registering the CPT: <?php add_action( ‘init’, ‘events_post_type_register’ ); function events_post_type_register() { $post_type = “events”; $labels = array( ‘name’ => _x(‘Events’, ‘post type general name’, ‘project_X’), ‘singular_name’ => _x(‘Event’, ‘post type singular name’, ‘project_X’), ‘add_new’ => _x(‘Add New’, ‘event’, ‘project_X’), ‘add_new_item’ => __(‘Add New Event’, … Read more

Custom Post Type Archive Page not showing

Navigate to Settings -> permalinks Change the permalink structure to Default Save settings Change to custom structure or post name (or any other structure) Save Settings This will re-write the htaccess file and then the re-write should work. If the above solution doesn’t work – it should be related to server configuration. Aapache2 Run: a2enmod … Read more

Custom Post Type Settings page, choose page to display archive

There is a dirty (actually dirty as hell) way to attach a ordinary WordPress page as archive page from a custom post type settings page. You need to unregister post type first, and create again. If you don’t use custom arguments or if you brave enough try this code. Add this code fragment end of … Read more