Custom post type is using the index.php template

public is false by default, your post type will not be visible on the front end without explicitly setting it to true. $post_args = array( ‘public’ => true, ‘label’ => _(‘Blog Post’), ‘description’ => _(‘Site\’s blog posts’), ‘show_ui’ => true, ‘show_in_nav_menus’ => true, ‘taxonomies’ => array(‘blog_posts’), ‘supports’ => array(‘title’, ‘editor’, ‘comments’, ‘trackbacks’, ‘thumbnail’), ‘capability_type’ => … Read more

WP overwrites my setup_postdata() setup

Should all CPT “lecture” posts use this template? If so, just rename your file single-lecture.php and place it in the root directory of your theme, and WP will automatically use it due to its template hierarchy. If instead you’re trying to assign this custom template to hand-picked pages, wherever you register your post type, add … Read more

How to get the current category with custom posts

The good basic technique to go from specifics to more general context is to look at the calls you already have. You already call single_cat_title(), which somehow knows current category, right? If you look inside you will see it passes call to single_term_title(). And how does that one in turn knows? $term = get_queried_object(); So … Read more

Need help with pagination

$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args_blog = array( ‘post_type’ => ‘post’, ‘paged’ => $paged, ‘posts_per_page’ => get_option(‘posts_per_page ‘) ); $query_blog = new WP_Query( $args_blog ); if($query_blog->have_posts()) : while($query_blog->have_posts()) : $query_blog->the_post(); $big = 999999999; // need an unlikely integer echo paginate_links( array( ‘base’ => str_replace( $big, ‘%#%’, esc_url( get_pagenum_link( $big ) ) ), ‘format’ … Read more

AMP version of front page without plugin

is_single() will return false for Pages, so the above code as written should only work for single Posts. You’ll need to add more conditionals to your amp_page_template() function for each of the templates you want to replace with an AMP version. Depending on your settings in Settings > Reading > Front page displays, is_front_page() might … Read more

Need to create a custom page on a website

First, if you want to build a custom page, the best place to look is the themes folder. If your working on a custom made theme, you can add templates to the theme folder, and use them in your site. Otherwise, it’s better to create a child theme for your customization (Childthemes). Within that new … Read more

What Must to Display the “mysite.com/category” URL?

“Can be avoided this “… can’t be found”?” To answer your question in one line: YES “Is this a normal behavior?” That’s because there’s no template file setup to display at that segment of the URL structure. By default, there’s no template for domain.com/category/ however, there is a template for domain.com/category/category-name/. WordPress refers to: domain.com/category/category-name/ … Read more