Why are the comments disabled by default on my custom_post_types?

Ok – so I solved this. Here is what appears to be the problem. Comments are disabled by default for custom-post-types. This happens even if you have them enabled in the overall settings To fix it, all I had to do was the following: In SETTINGS > DISCUSSION uncheck the “Allow people to post comments … Read more

Inconsistent temporary 404s on whole install | PHP error with post-template.php

There are two types of 404 errors: WordPress-generated, and server-generated. In some server environments, 404s could be inaccurately displayed by the server in cases of CPU overload or due to certain instances of misconfiguration, etc. Usually server-generated 404 errors will say something like “Nginx” or “Apache” at the bottom of the page (depends on server … Read more

WordPress Rewrite Rules for Custom Post Type and Taxonomy

Hope this can solve your problem function my_custom_post_type() { $labels = array( ‘name’ => _x(‘Projects’, ‘post type general name’), ‘singular_name’ => _x(‘Project’, ‘post type singular name’), ‘add_new’ => _x(‘Add New’, ‘project item’), ‘add_new_item’ => __(‘Add New Project’), ‘edit_item’ => __(‘Edit Project’), ‘new_item’ => __(‘New Project’), ‘view_item’ => __(‘View Project’), ‘search_items’ => __(‘Search Projects’), ‘not_found’ => … Read more

How to add custom post type archive page links to nav menu?

This is one method that I think should work (though it’s not tested). //Hook on to the filter for the (custom) main menu // ‘wp_list_pages’ filter is a fallback, when a custom menu isn’t being used add_filter( ‘wp_list_pages’, ‘new_nav_menu_items’ ); add_filter( ‘wp_nav_menu_items’, ‘new_nav_menu_items’ ); //Can also hook into a specific menu… //add_filter( ‘wp_nav_menu_{$menu->slug}_items’, ‘new_nav_menu_items’ ); … Read more

Use a separate upload folder for custom post attachment upload

I ended up solving it by completely bypassing the wp upload system, so this is how it looks now: /* * Define new upload paths */ $uploadfolder = WP_CONTENT_DIR . ‘/exames’; // Determine the server path to upload files $uploadurl = content_url() . ‘/exames/’; // Determine the absolute url to upload files define(RM_UPLOADDIR, $uploadfolder); define(RM_UPLOADURL, … Read more

Mixing regular and custom post types (with meta_query) on home page

There are different way to do the trick, 2 comes into my mind: use a complete custom $wpdb query use WP_Query with filters, using WP_Meta_Query to build the additional sql I’ll post here sample code for case #2 /** * Run on pre_get_posts and if on home page (look at url) * add posts_where, posts_join … Read more

How to get the posts of a custom taxonomy term

This question has different answers in this specific WordPress question, they may be of help: Display all posts in a custom post type, grouped by a custom taxonomy Personally I used this method that worked for me just fine: $terms = get_terms(‘tax_name’); $posts = array(); foreach ( $terms as $term ) { $posts[$term->name] = get_posts(array( … Read more

WordPress 3.3 custom post type with /%postname%/ permastruct?

This isn’t easily done in WP 3.3 unless you trick the rewrite rules to be in the correct spot and make wp_rewrite think verbose rules are being used in the front end. The class below works. class Test_Post_Type { const POST_TYPE = ‘test’; public static function init() { global $wp_rewrite; $post_type_obj = register_post_type( self::POST_TYPE, array( … Read more

Custom rewrite rules for archive page and single post

I found solution! A Monkeyman Rewrite Analyzur plugin was very helpful: https://wordpress.org/plugins/monkeyman-rewrite-analyzer/ So now, I have such working urls… single.php: /magazine-name/issue-year/issue/article-name archive.php: /magazine-name/issue-year/issue /magazine-name/issue-year /magazine-name On a custom post editor page in wp-admin I use Advanced Custom Fields plugin for issue year and issue. You can also define meta fields by yourself. Next I added … Read more