0

I'm using a plugin that creates a projects custom post type called wm_projects.

I configured my archive-wm_projects.php template to show the overview on /projects/ and my single page template, single-wm_projects.php, on URL /projects/1st-project/.

Now I want to use a WordPress page that loads the archive-wm_projects.php template because I want to use the URL structure and the page title (currently this is projects archive), I also want to upload an image there for my header.

Also, I'm using the Yoast SEO plugin.

I've Been looking for an answer that fits my needs, but doesn't look like anyone else wants to configure the site in this way.

[EDIT1]

Let me try to explain it a bit more. I'm using a childtheme, those files are listed in my childtheme

Projects archive
The page i want the projects to been showing, this is using the page-template-archive-wm_projects.php template

page-template-archive-wm_projects.php

<?php 
/**
 * Template Name: Project Archives
 */

require( locate_template( 'archive-wm_projects.php' ) );

exit();

archive-wm_projects.php

<?php get_header(); ?>

<?php // START if have posts ?>
<?php if ( have_posts() ) : ?>
    <div id="wrap">
        <div id="content" role="main">
            <div class="container">
                <div class="row">
                    <?php while ( have_posts() ) : the_post(); ?>
                        <?php
                            get_template_part( 'portfolio_overview' );
                        ?>
                    <?php endwhile; ?>
                </div>
            </div>
        </div>
    </div>
<?php endif; ?>
<?php get_footer(); ?>

portfolio_overview.php

<div class="col-sm-4">
    <div class="project-header">
        <?php $pageHeader = get_field('project_header'); ?>
        <img src="<?php echo $pageHeader['url']; ?>" alt="<?php echo $pageHeader['alt']; ?>" />
    </div>
    <header>
        <?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
    </header>
    <div class="readMore">
        <a href="<?php get_permalink() ?>">Lees verder</a>
    </div>
</div>
0

You can create a page template named template-page-projects-archive.php (for example) that contains the following code:

<?php 
/**
 * Template Name: Project Archives
 */

require( locate_template( 'archive-wm_projects.php' ) );

exit();

When editing a page where you'd like to use the archive-wm_projects.php template, just select Project Archives from the template dropdown.

  • Edit Sorry, thought this solved the issue, but somehow it's not working. It's not loading my custom post type item's this way.. It's now just showing the page title.. in the css/html style my archive was made – user2860384 Nov 9 '16 at 9:07
  • Are you sure you want to load the entire archive-wm_projects.php template? Maybe you need a different approach all together? – Dave Romsey Nov 9 '16 at 19:19
  • Added more to OP, hope this helps to explain what i have and what i want – user2860384 Nov 9 '16 at 20:05
  • I don't think the approach of using the entire archive template is going to work without at least altering the query. It sounds like you still want to use data from the page (header image) so the archive-wm_projects.php template may not be suitable when viewing items via the page. You might get some better answers if you provide the contents of your archive template. Another possible approach is to use a new page template that just pulls in template parts from the archive-wm_projects.php template, but we'd need to see your templates to advise on how to accomplish that. – Dave Romsey Nov 9 '16 at 20:24
  • What template do you want to see? This is all i have right now for the page. I have a page in wordpress using the 'page-template-archive-wm_projects.php' template. That one includes the 'archive-wm_projects.php' template. This is all the code those templates have right now. I just dont understand why wordpress won't load my projects on a page that includes the archive template of it. While the archives is showing the projects properly.. I'm not sure what you want to see more right now to help me with this – user2860384 Nov 9 '16 at 21:40

Your Answer

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

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