[Resolved] Question on taxonomy-custom.php and the GP “content” path

Home Forums Support [Resolved] Question on taxonomy-custom.php and the GP “content” path

Home Forums Support Question on taxonomy-custom.php and the GP “content” path

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1367299
    Henry

    I am trying to create a template for Custom Taxonomy, using the archive page template.

    To do this, typically (as I understand it) you simply copy/paste the archive.php page and rename it taxomony-{slug}.php with the “slug” being the name of the Custom Taxonomy.

    All nice and simple and that works.

    I have a child theme setup and I placed the taxomony-{slug}.php in there and it worked just fine.

    However, I notice that in GeneratePress there is this code:

    /*
     * 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', get_post_format() );

    So, what I thought would work would be me copy/pasting the content.php file, modifying it, then placing the renamed content-my-slug.php like this:

    /*
     * 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-my-slug.php', get_post_format() );

    ^ I placed this in the child theme and it didn’t work.

    So! My question is, what is the correct way of finding the ‘content-my-slug.php’ in my child theme? Do I need to add more code? WordPress can’t seem to find it.

    Thanks!

    #1367300
    Henry

    I guess the answer lies in here:

    (where ___ is the Post Format name) and that will be used instead

    What is this? Is the “Post Format Name” the same as the taxonomy slug?

    #1367613
    David
    Staff
    Customer Support

    Hi there,

    do you need to change the taxonomy content ?
    If it works how you want it then there is no need to create a separate content template.
    Let me know

    #1368207
    Henry

    Thanks, David, in fact, I need to remove the archive loop from that particular Custom Taxonomy archive page.

    I’m thinking it would be best to do that with the template option here:

    /*
     * 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-my-slug.php', get_post_format() );

    The issue I have is understanding how to link to the file “content-my-slug.php”

    Hope that makes sense and my approach does too

    Thanks

    #1368833
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try this instead:

    get_template_part( 'content', 'my-slug' );

    This assumes there’s a file named: content-my-slug.php

    Let me know ๐Ÿ™‚

    #1371810
    Henry

    worked great thanks

    #1372399
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.