Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Jetpack Portfolio Project in WordPress child theme does not call archive custom template

I have a child theme that uses the new Jetpack Portfolio Project custom post type and wish to modify archive.php to display custom results.

I'm using: WordPress v3.9.2; Theme: Child of Point, Jetpack is installed with Custom Content Types enabled, and Portfolio Projects selected in the Settings. (No other plugins that implement portfolio functionality are installed.)

According to the Codex:

Template Files

In the same way single posts and their archives can be displayed using the single.php and archive.php template files, respectively,

  • single posts of a custom post type will use single-{post_type}.php
  • and their archives will use archive-{post_type}.php
  • and if you don't have this post type archive page you can pass BLOG_URL?post_type={post_type}

where {post_type} is the $post_type argument of the register_post_type() function.

My understanding is that if you create files called single-jetpack-portfolio.php and archive-jetpack-portfolio.php within the child theme, WordPress will automatically use those files in place of single.php and archive.php respectively.

However, my child theme successfully calls single-jetpack-portfolio.php, but completely ignores archive-jetpack-portfolio.php, instead calling archive.php in the child.

I am stuck for a solution.

From the codex above, adding to the URL "?post_type=jetpack-portfolio" does cause the child theme to correctly use archive-jetpack-portfolio.php, but should I need to be manually modifying every single URL to explicitly specify this? Should WordPress not automatically be detecting this, as it does for the single-jetpack-portfolio.php file? How can I solve this?

I have tried:

  • Resetting the permalinks in case it was related to that (changing the option in Settings and saving and back again)
  • Adding an archive.php file to the child in addition to archive-jetpack-portfolio.php (I initially didn't have an archive.php in the child, so it used the parent's archive.php)
  • Publishing a new Jetpack portfolio project and updating an existing page (I read somewhere that publishing something might trigger Wordpress to see the changes)

Thanks in advance for any help.

like image 877
user145959 Avatar asked Oct 21 '22 03:10

user145959


2 Answers

I had the same problem described by the OP. When I visited mydomain.com/portfolio it would use the custom archive template. When I tried to view a project type it defaulted to the regular archive.php. I'm wondering if OP was viewing a project type page without realizing it.

My solution was to create a taxonomy template file. After playing around with it I figured out that

  • taxonomy.php
  • taxonomy-jetpack-portfolio-type.php
  • taxonomy-jetpack-portfolio-type-{name-of-project-type}.php

all worked correctly, depending on how specific you wanted to get.

There's more info at the wordpress codex: http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display

Hope this helps someone.

like image 168
Wesley Avatar answered Oct 28 '22 20:10

Wesley


I will be working on this the next days.

You should try this in the child archive.php first lines:

<?php
    if( is_post_type_archive('jetpack-portfolio') )
        get_template_part('content', 'jetpack-portfolio');

    elseif( is_tax('jetpack-portfolio-type') || is_tax('jetpack-portfolio-tag') )
        get_template_part('archive', 'jetpack-portfolio');

    else continue;
?>
like image 25
Raul Illana Avatar answered Oct 28 '22 20:10

Raul Illana