I'm working on an addition to my Wordpress Theme and I have a problem:

  • Theres the "/" which displays all of my posts excluding posts with the category "photos"
  • Then there's "/category/photos" for which I created the file "category-photos.php", since the theme styles everything with archive.php

Now what I need is: the category page should look the same as the homepage (same styling, same displaying of posts) and I just have no idea how to accomplish this. Is there a simple way I can achieve this?

Normally I just read here, but I can't seem to solve this problem on my own, that's why I created an account.

Here's what the category-photos.php looks like right now (copied this from archive.php)

<?php get_header(); ?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">

    <?php if ( have_posts() ) : ?>

        <header class="page-header">
                the_archive_title( '<h1 class="page-title">', '</h1>' );
                the_archive_description( '<div class="page-description">', '</div>' );
        </header><!-- .page-header -->

        <?php /* Start the Loop */ ?>
        <?php while ( have_posts() ) : the_post(); ?>

                /* Include the Post-Format-specific template for the content.
                 * If you want to override this in a child theme, then include a file
                 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                get_template_part( 'content-archive', get_post_format() );

        <?php endwhile; ?>

        <?php the_posts_navigation(); ?>

    <?php else : ?>

        <?php get_template_part( 'content', 'none' ); ?>

    <?php endif; ?>

    </main><!-- #main -->
</div><!-- #primary -->
  • You could copy the content op index.php and put it in category-photos.php. Whether this will work depends on how the theme is structured. There's not enough information in your question to say a lot more about this. – cjbj Jan 31 '17 at 18:34
  • I tried this already, but that didn't work. The theme I'm using is Magnus and can be found here: magnus.thefivethemes.com – Manuel Jan 31 '17 at 18:51
  • cjbj is right -- that should be the first approach. You say it didn't work, but can you be more specific? What was wrong when you tried it? – Greg Burkett Jan 31 '17 at 22:57
  • I tried copying index.php to content-archive.php, which destroyed the category page. Then I tried copying the index.php to archive.php, which didn't change the category page at all. When I copy index.php to category-photos.php it doesn't change anything either. EDIT: I also tried to copy home.php to category-photos.php. This changed the layout, but it still doesn't display any photos. :( – Manuel Feb 1 '17 at 12:40
  • I used the plugin "what the file" to find out which parts of the theme are loaded when viewing the homepage: it loads home.php and content-home.php as template part. Now I changed everything so category-photos.php loads home.php (copied this over) and content-home.php as well, but that still doesn't display it the way I'd like it to. – Manuel Feb 1 '17 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.