• Resolved Parsa

    (@parselearn)


    hi
    my custom post type, create for news blog
    CPT when user login: correct permalink & show post content & select specific theme
    for example URL: https://domain.tld/news/20module/

    but when dont login: permalink dont work, don’t show post content, dont select specific theme
    for example URL: for example URL: https://domain.tld/20module/

    my code:

    $labels = array(
            'name' => '??????',
            'singular_name' => '???',
            'add_new' => '?????? ???',
            'add_new_item' => '?????? ??? ????',
            'edit_item' => '?????? ???',
            'new_item' => '??? ????',
            'view_item' => '????? ???',
            'search_items' => '?????? ???',
            'not_found' => '???? ???? ???? ???',
            'not_found_in_trash' => '????? ?? ????????? ???? ???',
            'parent_item_colon' => '?????',
            'menu_name' => '????? ???????',
        );
    
        $args = array(
            'labels' => $labels,
            'hierarchical' => false,
            'description' => '????? ????',
            'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),  //'page-attributes'
            'taxonomies' => array( 'page-category' ),
            'public' => true,
            'show_ui' => true,
            'show_in_menu' => true,
    		'menu_position' => 7,
            'menu_icon' => plugins_url('shoppress/images/module/news.png'),
            'show_in_nav_menus' => true,
            'publicly_queryable' => true,
            'exclude_from_search' => true,
            'has_archive' => true,
            'query_var' => true,
            'can_export' => true,
            'rewrite' => array('slug' => 'news'),
    		'_builtin' => false,
            'capability_type' => 'post'
        );
    
        register_post_type( 'news', $args );
    
    	//register_taxonomy("newscat", array("news"), array("hierarchical" => true, "label" => "???????", "singular_label" => "???????", "rewrite" => array( 'slug' => 'news', 'with_front' => false )));
    
    	$labels = array(
        'name'                          => '???????',
        'singular_name'                 => '???????',
        'search_items'                  => '?????? ????',
        'popular_items'                 => '????? ??????? ???',
        'all_items'                     => '???? ?????',
        'parent_item'                   => '???? ????',
        'edit_item'                     => '?????? ????',
        'update_item'                   => '????????? ????',
        'add_new_item'                  => '?????? ???? ????',
        'new_item_name'                 => '???? ????',
        'separate_items_with_commas'    => '??????? ??????? ?? ????',
        'add_or_remove_items'           => '?????? ?? ??? ????',
        'choose_from_most_used'         => '?????? ?? ???????'
        );
    
    	$args = array(
    		'label'                         => '?????',
    		'labels'                        => $labels,
    		'public'                        => true,
    		'hierarchical'                  => true,
    		'show_ui'                       => true,
    		'show_in_nav_menus'             => true,
    		'args'                          => array( 'orderby' => 'term_order' ),
    		'rewrite'                       => array( 'slug' => 'newscat', 'with_front' => true ),
    		'query_var'                     => true
    	);
    
    	register_taxonomy( 'newscat', 'news', $args );
  • The topic ‘custom post type work when user login!’ is closed to new replies.