• Resolved smsaikat

    (@smsaikat)


    I am developing a wordpress theme. In my theme there are a custom post type ‘project’. This ‘project’ post type using archive.php page to index all projects . I want to use archive.php also for indexing wordpress default posts those are coming from default post type ‘post’. How can i do this ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Kindly invest a little time to WordPress’ Template Hierarchy to understand what template files are used for what pages/views on a WordPress site.

    And here’s a handy visual guide: https://wphierarchy.com/

    But to answer your specific question, for the blog posts index page, the home.php template file is first searched and used if available. The index.php template file (UPDATE: I mistakenly wrote archive.php earlier on) is only used if home.php is not available.

    • This reply was modified 3 years, 9 months ago by George Appiah. Reason: Corrected template file mistake
    Thread Starter smsaikat

    (@smsaikat)

    Thank you for your reply, I know about Template Hierarchy’. But I want to show both blog index and custom post index in archive.php , Is it possible? Currently for blog index page wordpress searching home.php and then its checking index.php

    I’m very sorry, I misread your post. I’ve corrected my response above.

    What you’re asking for is not the default WordPress behaviour.

    But it’s just PHP, and it should be easy to override the default template hierarchy and serve a different template file or even a custom file. You could, for instance, add a bit of code in your functions.php file to check what page you’re on (using the conditional tags) and load the desired template file.

    Here’s a quick tutorial with sample code: https://www.bynicolas.com/code/override-template-hierarchy/

    Thread Starter smsaikat

    (@smsaikat)

    Thank you so much,, its working ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How can i use archive.php for indexing wordpress default posts?’ is closed to new replies.