• Dear All,

    I am a new programmer with WordPress. I try to create custom post type
    with my project.
    My problem is I want to get the slug of eahc category of the catalog:
    If any one know about this please help me.

    Thanks In advances!

    The code I used like this:

    add_action(‘init’, ‘product_register’);
    function product_register(){
    $args = array(
    ‘label’ => __(‘Products’),
    ‘singular_label’ => __(‘Product’),
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘capability_type’ => ‘post’,
    ‘hierarchical’ => false,
    ‘rewrite’ => true,
    //’permalink_epmask’=>’EP_PERMALINK ‘,
    ‘rewrite’ => array( ‘slug’ => ‘product’, ‘with_front’ => true), //Rewrite for singular product
    ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’, ‘custom-fields’)
    );
    register_post_type( ‘product’ , $args );
    }
    ?>
    <?php
    add_action(“admin_init”, “admin_init”);
    add_action(‘save_post’, ‘save_price’);

    function admin_init(){
    add_meta_box(“prodInfo-meta”, “Product Options”, “meta_options”, “product”, “side”, “low”);
    }

    function meta_options(){
    global $post;
    $custom = get_post_custom($post->ID);
    $price = $custom[“price”][0];
    ?>
    <label>Price:</label><input name=”price” value=”<?php echo $price; ?>” />
    <?php //End 0f Product Optoins ?>
    <?php
    }

    function save_price(){
    global $post;
    update_post_meta($post->ID, “price”, $_POST[“price”]);
    }

    register_taxonomy(“catalog”, array(“product”), array(“hierarchical” => true, “label” => “Catalogs”, “singular_label” => “Catalog”, “rewrite” => true));
    ?>
    <?php
    add_filter(“manage_edit-product_columns”, “prod_edit_columns”);
    add_action(“manage_posts_custom_column”, “prod_custom_columns”);

    function prod_edit_columns($columns){
    $columns = array(
    “cb” => “<input type=\”checkbox\” />”,
    “title” => “Product Title”,
    “description” => “Description”,
    “price” => “Price”,
    “catalog” => “Catalog”,
    );

    return $columns;
    }

    function prod_custom_columns($column){
    global $post;
    switch ($column)
    {
    case “description”:
    the_excerpt();
    break;
    case “price”:
    $custom = get_post_custom();
    echo $custom[“price”][0];
    break;
    case “catalog”:
    echo get_the_term_list($post->ID, ‘catalog’, ”, ‘, ‘,”);
    break;
    }
    }
    add_action(‘init’, ‘flush_rewrite_rules’);//Mod_Rewrite
    ?>

The topic ‘Custom post type permalink’ is closed to new replies.