Custom Post Type order Title ASC

$index = ‘A’; $terms = get_terms(‘manufacturer’); foreach ($terms as $term) { if($index != strtoupper(substr($term->name, 0, 1))) { $index = strtoupper(substr($term->name, 0, 1)); echo ‘<h1>’. $index . ‘</h1>’; } ?> <h2><?php echo $term->name; ?></h2> <?php $args = array( ‘post_type’ => ‘cars’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => … Read more

Removing custom post type name in single article URLs

Use the post_type_link hook, like this for use hash in link faq is the example custom post type add_action( ‘post_type_link’, ‘wpse70763_post_type_link’, 10, 2 ); function wpse70763_post_type_link( $link, $post ) { $post_type=”faq”; if ( $post->post_type === $post_type ) $link = get_post_type_archive_link( $post_type ) . ‘#’ . $post->post_name; return $link; } then unset($wp_rewrite->extra_permastructs[‘faq’]) On the init of … Read more

Random ID for custom post type

the_ID() must be within The Loop. from the_ID codex page global $post will merely get the last post that was set as the global post object which will depend greatly on what is done in the rest of the request. If somewhere in your header template, page template or content template you change or modify … Read more