Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter sbhagirath

    (@sbhagirath)

    I have create a custom post type and code is below :

    add_action( ‘init’, ‘register_cpt_top_ten’ );
    function register_cpt_top_ten() {
    $labels = array(
    ‘name’ => _x( ‘Top Ten’, ‘top_ten’ ),
    ‘singular_name’ => _x( ‘Top Ten’, ‘top_ten’ ),
    ‘add_new’ => _x( ‘Add New’, ‘top_ten’ ),
    ‘add_new_item’ => _x( ‘Add New Top Ten’, ‘top_ten’ ),
    ‘edit_item’ => _x( ‘Edit Top Ten’, ‘top_ten’ ),
    ‘new_item’ => _x( ‘New Top Ten’, ‘top_ten’ ),
    ‘view_item’ => _x( ‘View Top Ten’, ‘top_ten’ ),
    ‘search_items’ => _x( ‘Search Top Ten’, ‘top_ten’ ),
    ‘not_found’ => _x( ‘No Top Ten found’, ‘top_ten’ ),
    ‘not_found_in_trash’ => _x( ‘No Top Ten found in Trash’, ‘top_ten’ ),
    ‘parent_item_colon’ => _x( ‘Parent Top Ten:’, ‘top_ten’ ),
    ‘menu_name’ => _x( ‘Top Ten’, ‘top_ten’ ),
    );
    $args = array(
    ‘labels’ => $labels,
    ‘hierarchical’ => false,
    ‘supports’ => array( ‘title’, ‘editor’, ‘excerpt’, ‘author’, ‘thumbnail’, ‘trackbacks’, ‘custom-fields’, ‘comments’, ‘revisions’, ‘page-attributes’ ),
    ‘taxonomies’ => array( ‘product_type’ ),
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘show_in_menu’ => true,
    ‘menu_position’ => 5,
    ‘show_in_nav_menus’ => true,
    ‘publicly_queryable’ => true,
    ‘exclude_from_search’ => false,
    ‘has_archive’ => true,
    ‘query_var’ => true,
    ‘can_export’ => true,
    ‘rewrite’ => true,
    ‘capability_type’ => ‘post’,
    ‘rewrite’ => array( ‘slug’ => ‘top_ten’ ),
    );
    register_post_type( ‘top_ten’, $args );
    flush_rewrite_rules();
    }

    and for I want to change url rewriting

    like this

    add_filter( ‘post_type_link’, ‘custom_post_type_link’, 10, 3);

    function custom_post_type_link($permalink, $post, $leavename) {
    if (!gettype($post) == ‘post’) {
    return $permalink;
    }
    switch ($post->post_type) {
    case ‘top_ten’:
    $permalink = get_home_url() . ‘/top-ten-best-‘ . $post->post_name . ‘/’;
    break;
    }

    return $permalink;
    }

    but it show 404 error

    Thread Starter sbhagirath

    (@sbhagirath)

    post_type_link show error

    Thread Starter sbhagirath

    (@sbhagirath)

    Hi oscargare,

    Thanks for your quick reply .

    I am using Version 2.4.7 of woocommerce and WordPress 4.1.8 running Virtue theme.
    Problem shown for both simple product as well as variable product . get_price() function return 0 value and also show Warning: Missing argument 2 for WCPBC_Frontend::get_price() in /home/fourfour2/public_html/wp-content/plugins/woocommerce-product-price-based-on-countries/includes/class-wcpbc-frontend.php on line 176

    Please solve my problem as soon as possible .

    Thanks
    sbhagirath

    Woo Commerce- Cart
    woocomerce cart is not update and Delete .
    I want to remove Item and change quantity but it still remain same …

    Please help

Viewing 4 replies - 1 through 4 (of 4 total)