Example #1
0
<?php

require_once 'my_post_types.php';
add_post_types('snippet', array('supports' => array('title', 'editor', 'comments', 'excerpt'), 'taxonomies' => array('post_tag')));
add_post_types('finance', array('supports' => array('title', 'editor')));
add_taxonomy('language', 'snippet', array('hierarchical' => true));
add_taxonomy('diffculty', 'snippet');
/**
 * Twenty Fifteen functions and definitions
 *
 * Set up the theme and provides some helper functions, which are used in the
 * theme as custom template tags. Others are attached to action and filter
 * hooks in WordPress to change core functionality.
 *
 * When using a child theme you can override certain functions (those wrapped
 * in a function_exists() call) by defining them first in your child theme's
 * functions.php file. The child theme's functions.php file is included before
 * the parent theme's file, so the child theme functions would be used.
 *
 * @link https://codex.wordpress.org/Theme_Development
 * @link https://codex.wordpress.org/Child_Themes
 *
 * Functions that are not pluggable (not wrapped in function_exists()) are
 * instead attached to a filter or action hook.
 *
 * For more information on hooks, actions, and filters,
 * {@link https://codex.wordpress.org/Plugin_API}
 *
 * @package WordPress
 * @subpackage Twenty_Fifteen
 * @since Twenty Fifteen 1.0
Example #2
0
        $args = array_merge(array('public' => true, 'label' => $caps, 'labels' => array('add_new_item' => "Add New {$caps}"), 'supports' => array('title', 'editor', 'comments')), $args);
        register_post_type($name, $args);
    });
}
add_post_types('about', array('supports' => array('title', 'editor', 'comments', 'excerpt', 'thumbnail'), 'taxonomies' => array('post_tag')));
add_post_types('finance', array('supports' => array('title', 'editor')));
//-----------------fucntion for custom taxonomies-----------------
function add_taxonomy($name, $post_type, $args = array())
{
    $name = strtolower($name);
    add_action('init', function () use($name, $post_type, $args) {
        $args = array_merge(array('label' => ucwords($name)), $args);
        register_taxonomy($name, $post_type, $args);
    });
}
add_taxonomy('about-category', 'about', array('hierarchical' => true));
add_action('add_meta_boxes', function () {
    add_meta_box('fh_pdf_info', 'Pdf Link', 'fh_pdf_info_cb', 'about', 'normal', 'high');
});
function fh_pdf_info_cb()
{
    global $post;
    $url = get_post_meta($post->ID, 'fh_pdf_url', true);
    //securtiy check
    wp_nonce_field(__FILE__, 'fh_nonce');
    ?>
	<label for="fh_pdf_url">Link PDF Document:</label>
	<input type="text" name="fh_pdf_url" id="fh_pdf_url" class="widefat" value="<?php 
    echo $url;
    ?>
" />