Create Template for Custom Post Type same like for Page

It sounds like you are talking about this page display template: page-{slug}.php – If the page slug is recent-news, WordPress will look to use page-recent-news.php And you want single-{cpt-slug}-{slug}.php. If so, I believe you can approximate that page template handling with the following: function cpt_slug_template_wpse_117630($template) { global $post; $templ = locate_template(‘single-‘.$post->post_type.’-‘.$post->post_name.’.php’); if ( ‘book’ == … Read more

Normal pages as children of my Custom Post Type

If it were me, here’s how I’d achieve this. Preface Assuming the following data structures: Post type: “dictionary” Taxonomy: “dictionary_category”, terms limited to single letters And the desired URLs: /dictionary/ => page (this should work out-of-the-box) /dictionary/rules/ => page /dictionary/x/ => Taxonomy archive /dictionary/x/xavier/ => Single post view 1. Set the post type and taxonomy … Read more

WordPress count child posts of each parent custom post type and use in json array for google maps jquery plugin

First of all you should alway separate php from javascript. Generally talking, it’s a bad practise mix them, and specifically to WordPress, it also force you to add javascript inline instead using the WordPress proper way: using wp_enqueue_script. When you need pass variables from PHP to javascript, the proper WordPress way to do it is … Read more

right_now_content_table_end function not working?

The new action is dashboard_glance_items. It is a filter providing an array to which you can add items. Example from my plugin T5 Taxonomy Location add_filter( ‘dashboard_glance_items’, array ( $this, ‘add_to_glance’ ) ); /** * Add locations to the new “At a glance” dashboard widget. * * @param array $items * @return array */ public … Read more

Query custom post type in the loop

You are probably getting a rewrite conflict with the has_archive argument here: $args = array( ‘labels’ => $labels, ‘description’ => ‘Holds our services and service specific data’, ‘public’ => true, ‘menu_position’ => 5, ‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’ ), ‘has_archive’ => true, ); Set has_archive to false if you do not want the automatically … Read more

Delete link on single-custom.php with redirection

Rather than “still on” page the user actually goes to the link and then sent back after post is deleted. From your description and quick look at code this is probably line that sends user back: wp_redirect( add_query_arg(‘deleted’, 1, $sendback) ); Since destination is filtered inside wp_redirect() $location = apply_filters( ‘wp_redirect’, $location, $status ); and … Read more

Hide specific parent categories from post edit

Probably you’re making a wrong use of taxonomies. Instead of using only the Categories taxonomy, you should create several Custom Taxonomies. I mean Blog Categories, Download Categories, Team Departments, etc… should be different taxonomies, and you should assing each of these taxonomies to the custom post type(s) they’re related to… Check the function register_taxonomy() for … Read more