Answers for "make custom post type in wordpress"

PHP
1

wp_query get custom post type

<?php    
  	   $args = array(  
      'post_type' => 'custom_type',
      'post_status' => 'publish',
      'posts_per_page' => 8, 
      'orderby' => 'title', 
      'order' => 'ASC', 
          );

  $loop = new WP_Query( $args ); 

  while ( $loop->have_posts() ) : $loop->the_post(); 
      print the_title(); 
      the_excerpt(); 
  endwhile;

  wp_reset_postdata(); 
  ?>
Posted by: Guest on November-27-2020
0

custom post type

.wp-block-code {
	border: 0;
	padding: 0;
}

.wp-block-code > div {
	overflow: auto;
}

.hljs {
	box-sizing: border-box;
}

.hljs.shcb-code-table {
	display: table;
	width: 100%;
}

.hljs.shcb-code-table > .shcb-loc {
	color: inherit;
	display: table-row;
	width: 100%;
}

.hljs.shcb-code-table .shcb-loc > span {
	display: table-cell;
}

.wp-block-code code.hljs:not(.shcb-wrap-lines) {
	white-space: pre;
}

.wp-block-code code.hljs.shcb-wrap-lines {
	white-space: pre-wrap;
}

.hljs.shcb-line-numbers {
	border-spacing: 0;
	counter-reset: line;
}

.hljs.shcb-line-numbers > .shcb-loc {
	counter-increment: line;
}

.hljs.shcb-line-numbers .shcb-loc > span {
	padding-left: 0.75em;
}

.hljs.shcb-line-numbers .shcb-loc::before {
	border-right: 1px solid #ddd;
	content: counter(line);
	display: table-cell;
	padding: 0 0.75em;
	text-align: right;
	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	user-select: none;
	white-space: nowrap;
	width: 1%;
}
// Register Custom Post Type - Workshop
function kp_workshops() {

	$args = array(
		'label' =>; __( 'Workshop', 'kp_workshops' ),
		'description' =>; __( 'Workshop listing', 'kp_workshops' ),
		'labels' =>; $labels,
		'supports' =>; array( 'title', 'editor', 'thumbnail', 'comments', 'revisions', 'custom-fields' ),
		'taxonomies' =>; array( 'category' ),
		'hierarchical' =>; false,
		'public' =>; true,
		'show_ui' =>; true,
		'show_in_menu' =>; true,
		'menu_position' =>; 20,
		'menu_icon' =>; 'dashicons-welcome-learn-more',
		'show_in_admin_bar' =>; true,
		'show_in_nav_menus' =>; true,
		'can_export' =>; true,
		'has_archive' =>; true,
		'exclude_from_search' =>; false,
		'publicly_queryable' =>; true,
		'capability_type' =>; 'page',
		'show_in_rest' =>; true,
	);

	register_post_type( 'workshops', $args );

}
add_action( 'init', 'kp_workshops', 0 );
Posted by: Guest on July-13-2020
0

wordpress custom post type Query

<?php 
    query_posts(array( 
        'post_type' => 'portfolio',
        'showposts' => 10 
    ) );  
?>
<?php while (have_posts()) : the_post(); ?>
        <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
        <p><?php echo get_the_excerpt(); ?></p>
<?php endwhile;?>
Posted by: Guest on June-07-2021

Code answers related to "make custom post type in wordpress"

Browse Popular Code Answers by Language