Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom post type single page not working

I have aj-fashions custom post type. technically i tried to show the loop of all post in a template file named fashio-template.php and now for the single post i have created file single-fashions.php. still i am getting 404 error of page not found.

Kindly advice, following is my code.

add_action( 'init', 'fashion' );
function fashion() {
  register_post_type( 'aj-fashion',
    array(
      'labels' => array(
        'name' => __( 'AJ Fasions' ),
        'singular_name' => __( 'AJ Fashion' )
      ),
        'public' => true,
        'has_archive' => true,
        'show_ui' => true,
        'hierarchical' => false,
        'rewrite' => array('slug' => 'aj-fashions',),
        'supports'=> array( 'title', 'editor', 'thumbnail', 'author' ),
    )
  );
}
like image 797
Salman Razak Avatar asked Nov 28 '25 00:11

Salman Razak


2 Answers

After creating single-{posttype}.php You just update your permalink. Got to Settings->permalinks. First time every developer face this problem.

like image 135
Md Al-Mahmud Avatar answered Nov 29 '25 16:11

Md Al-Mahmud


After creating single-{posttype}.php You just update your permalink.

And this not worked than use this function

Put in functions.php flush_rewrite_rules( false );

like image 35
hiren panchal Avatar answered Nov 29 '25 15:11

hiren panchal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!