Hidden Custom Post Type

If you want it to be visible everywhere (i.e. search), just without the admin menu, then something to the effect of the following should do the trick when added to functions.php in the theme directory: register_post_type( ‘project’, array( ‘labels’ => array( ‘name’ => _x( ‘Projects’, ‘post type general name’, ‘namespace’ ), ‘singular_name’ => _x( ‘Project’, … Read more

Why was my plugin rejected from the WordPress.org repository?

This is because you directly call a PHP file from within your plugin folder. This is bad for two reasons, the first being that some people block direct access to PHP files inside the wp-content folder. The second is you need to include wp-load.php to access the WordPress API. Instead of linking to… site_url().””.”/wp-content/plugins/Printer-Friendly-WP/print.php?id=page_id=”.””. get_the_ID()` … Read more

wp_count_posts on all post types?

To get the custom post types you would call the get_post_types function.The built-in public post types are post, page, and attachment. By setting ‘_builtin’ to false, we will exclude them and show only the custom public post types. Below is the code. <?php $args = array( ‘public’ => true, ‘_builtin’ => false ); $output=”names”; // … Read more

Custom Taxonomy Not Showing in Menu

As seen in the Codex: http://codex.wordpress.org/Function_Reference/register_taxonomy <?php add_action( ‘init’, ‘create_book_tax’ ); function create_book_tax() { register_taxonomy( ‘genre’, ‘book’, array( ‘label’ => __( ‘Genre’ ), ‘rewrite’ => array( ‘slug’ => ‘genre’ ), ‘hierarchical’ => true, ) ); } ?> From what I see in your code, you are not linking the taxonomy to your post-type. Try changing … Read more

Use WP_Theme::scandir function to scan a plugin directory. Is there a way?

You can use PHP5 RecursiveDirectoryIterator with RecursiveIteratorIterator $directory = ‘/project_root/wp-content/plugins/your-plugin’; //Your plugin dir $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); while ($it->valid()) { //Check the file exist if (!$it->isDot()) { //if not parent “..” or current “.” if (strpos($it->key(), ‘.php’) !== false || strpos($it->key(), ‘.css’) !== false || strpos($it->key(), ‘.js’) !== false ) { //Do your stuff … Read more