Custom post type as child of page

If you want your custom post type listed under a page you can add the permalink of the page to the rewrite slug like so: register_post_type(‘my_books’, array( ‘has_archive’ => false, // Stops domain.com/book becoming the cpt’s archive ‘rewrite’ => array(‘slug’ => ‘book’) )); You need to visit Settings->Permalinks after making any changes to permalinks to … Read more

How can I use this code on a custom database table?

Yes you have to write a custom function and call it on your manage columns it will help you to get the necessary contents. public function xxxx_get_cpt_data($post_ID) { // $cpt_values = get_post_custom($post_ID); global $wpdb; $sql = “SELECT * FROM “. $wpdb->prefix. “custom_table WHERE post_ID=”. $post_ID. ” LIMIT 1″ ; $cpt_values = $wpdb->get_results($sql); if ($cpt_values) { … Read more

Create metaboxes based on custom post type

When defining your MetaBox before registering it, just set the PostTypes it is applicable for: $f711_meta_boxes[] = array( ‘id’ => ‘details’, ‘title’ => __( ‘Details’, ‘f711_theme’ ), ‘pages’ => array( ‘publicity’ ), // change this values ‘context’ => ‘normal’, ‘priority’ => ‘high’, ‘fields’ => array( array( ‘name’ => __( ‘Fischi ist’, ‘f711_theme’ ), ‘desc’ => … Read more

admin-ajax.php GET custom-post titles

First replace: resgister_post_type with: register_post_type to fix the typo. Secondly replace: while( $portfolio_query->have_post() ){ with while( $portfolio_query->have_posts() ){ where you’ve forgotten the plural s. Note The reason why calling non-existing methods like: $portfolio_query->some_non_existent_method() doesn’t raise a PHP error, is the magic __call method of the WP_Query class: /** * Make private/protected methods readable for backwards … Read more