How to Add a Sub Menu Page to a Custom Post Type?

add_options_page() automatically adds it underneath settings, however add_submenu_page() gives you control as to where you want it to show up. Try something like this: add_submenu_page( ‘edit.php?post_type=portfolios’, __( ‘Test Settings’, ‘menu-test’ ), __( ‘Test Settings’, ‘menu-test’ ), ‘manage_options’, ‘testsettings’, ‘mt_settings_page’ );

Programmatically publish a post (custom post type) with custom fields

Use wp_insert_post() and add_post_meta(), like this: // insert the post and set the category $post_id = wp_insert_post(array ( ‘post_type’ => ‘your_post_type’, ‘post_title’ => $your_title, ‘post_content’ => $your_content, ‘post_status’ => ‘publish’, ‘comment_status’ => ‘closed’, // if you prefer ‘ping_status’ => ‘closed’, // if you prefer )); if ($post_id) { // insert post meta add_post_meta($post_id, ‘_your_custom_1’, $custom1); … Read more

single-{$post_type}-{slug}.php for custom post types

A) The Base in Core As you can see in the Codex Template Hierarchy explanation, single-{$post_type}.php is already supported. B) Extending the core Hierarchy Now there’re gladly some filters and hooks inside /wp-includes/template-loader.php. do_action(‘template_redirect’); apply_filters( ‘template_include’, $template ) AND: a specific filter inside get_query_template( $type, … ) named: “$type}_template” B.1) How it works Inside the … Read more

get_terms by custom post type

I’m afraid this isn’t possible natively (yet?). See this trac: http://core.trac.wordpress.org/ticket/18106 Similarly on the taxonomy admin page the post count reflects all post types. (I’m pretty sure there is a trac ticket for that too) http://core.trac.wordpress.org/ticket/14084 See also, this related post. New solution Having written the one below, I’ve released a much better way (alteast … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)