Custom Post Type


Custom Post Type

Show Custom Post types on page

<?php
$args = array( 'post_type' => 'POST_TYPE', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();

the_title();

endwhile;  wp_reset_query();?>

Fight with 404 error

Change custom permalink to: /%category%/%post_id%/%postname%

Add category // and some other stuff


<?php array(
'label' => 'ADD SOMETHINGS',
'taxonomies' => array('category'), // add this!!

'singular_label' => 'ADD SOMETHING',
'_builtin' => false,
'exclude_from_search' => false, // Exclude from Search Results
'capability_type' => 'page',
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => false,
'rewrite' => array(
'slug' => 'elamud_ja_krundid',
'with_front' => FALSE,

), ?>

Get Category Name by Post ID


<?php $id = get_the_ID(); //get id
$category = get_the_category( $id );
echo $category[0]->cat_name; ?>

+ There are no comments

Add yours