• Resolved Trialstyle

    (@trialstyle)


    Hello,
    I have wordpress with Primer Theme installed. I wanted to change the look of my archive and had to add some divs and some classes. To do so I tried to change the archive.php. Nothing happened so I installed the Reveal Template plugin to see which template is used for my current archive. This said that index.php is used. I want it to use archive.php (and i thought this is first choice?!). Does primer change something in there? How can I fix that? My Blog page is not my front page.
    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @trialstyle,

    When you say you want to change the look of your archive, are you referring to the blog listing page itself? The archive.php template is used for categories, tags, custom taxonomies, custom post types, authors and dates.

    index.php is used for your blog page, not the home page. Whatever you have set on ‘Settings > Reading > Blog’ is what will reference index.php.

    If you want to make changes to your blog page you’ll want to make a child theme of Primer and copy over the files out of the root directory or the appropriate template files from within the /templates/ directory of the parent Primer theme.

    You can always reference the Template Hierarchy article for additional info.

    Additionally, if you just want to add classes to the divs of the blog page, you can hook into the filter post_class and add the classes that way.

    Example:

    /**
     * Add custom classes onto the blog post divs.
     *
     * @param  array  $classes  An array of post classes.
     * @param  string $class    An array of additional classes added to the post.
     * @param  int    $post_id  The post ID.
     *
     * @return array            Filtered post classes array.
     */
    function primer_custom_post_classes( $classes, $class, $post_id ) {
    
    	if ( ! is_home() ) {
    
    		return $classes;
    
    	}
    
    	$classes[] = 'custom-class';
    
    	return $classes;
    
    }
    add_filter( 'post_class', 'primer_custom_post_classes', 10, 3 );
    Thread Starter Trialstyle

    (@trialstyle)

    Thanks, helped a lot! Created the home.php template now in my child theme.

    Awesome – not a problem at all. Glad I could help point you in the right direction. Have a great week!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Archive does not use archive.php template’ is closed to new replies.