Open Custom Post Type as PDF

You may want to try a few PDF generation plugins out there. I did some quick Googling and found https://wordpress.org/plugins/wp-pdf-generator/ (but I would recommend searching for others). Once installed, you can directly link your users to the “generate pdf” link instead of the Custom Post Type permalink, generating the PDF automatically for them. You can … Read more

Custom template won’t load for a custom post type (custom permalinks used)

The problem in your code is the lack of proper rules. You add ‘rewrite’ => ‘CPT/%states%’ in register_post_type() arguments. This causes that the rules generated for pathologists post type begins with pathologists/%states%/ and the address pathologists/alabama/ (pathologists/{term}/) will not be matched. More importantly, all posts from the custom category are displayed regardless of the type, … Read more

Remove post type slug of all post types from permalinks

function gp_remove_cpt_slug( $post_link, $post ) { if ( ‘race’ === $post->post_type && ‘publish’ === $post->post_status ) { $post_link = str_replace( “https://wordpress.stackexchange.com/” . $post->post_type . “https://wordpress.stackexchange.com/”, “https://wordpress.stackexchange.com/”, $post_link ); } return $post_link; } add_filter( ‘post_type_link’, ‘gp_remove_cpt_slug’, 10, 2 ); At this point, trying to view the link would result in a 404 (Page Not Found) error. … Read more

CPT Archive with core Category

You want display posts of a given type ({post_type}) from category ({term}) and structure of link should looks like this: {post_type} / category / {term} To avoid collisions with links to pages and “blog” posts, expression can not start with ([^/]+), but should contain slug of post type entered explicitly. This means a separate rule … Read more

How to avoid manage posts screen duplicates when two plugins use the same library

In your code, you add the filter like this: add_action( ‘restrict_manage_posts’, array( $this, ‘restrict_log_posts’ ) ); Which adds a function that starts like this: public function restrict_log_posts() { $type=”wp_log”; $taxonomy = ‘wp_log_type’; // only add filter to post type you want if ( isset( $_GET[‘post_type’] ) && esc_attr( $_GET[‘post_type’] ) === $type ) { // … Read more