3

I've been tasked with creating a portfolio website for a client who also wants a blog.

What I've Done Thus Far: I’ve created a custom post type to separate the portfolio work from the blog posts and created a WP_Query to display them on my front-page.php.

The Problem: Now that my front-page.php displays my custom post type (and not my WordPress' builtin posts), I'm not sure how to navigate to my blog archive. What template do I use to create said archive (i.e. index.php, home.php, archive.php, etc) and would I navigate to it?

2 Answers 2

2

Create a template with a WP_Query to get posts with post type "post" then create a page and assign that template to that page.

Templates: https://codex.wordpress.org/Templates

Query by post type: https://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters

3
  • 1
    What would the url be? How would I navigate to it?
    – Wilhelm
    Jul 26, 2015 at 0:15
  • Set the template to a page of your choice. And the url would be www.sitename.com/pagename
    – thebigtine
    Jul 26, 2015 at 10:38
  • This answer could be improved by linking to a more specific codex article than the general templates topic overview. Aug 25, 2023 at 13:16
1

You need to create an archive.php template for the standard posts (if you don't already have one). You can even create different ones for the standard 'category' and 'tag' archives.

Check the template hierarchy rules here for more explanations: https://developer.wordpress.org/themes/basics/template-hierarchy/#category

Also, when you want to see which template you're seeing in the browser, feel free to add this code:

// Show Template in footer
function show_template() {
  if( is_super_admin() ){
    global $template;
    print_r($template);
  } 
}
add_action('wp_footer', 'show_template');

^this will display the template inside the footer.

2
  • This does not solve the problem if we want to define an archive page independent of a specific category. Aug 25, 2023 at 13:13
  • Really? Have you tried to implement an archive.php template? Aug 25, 2023 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.