[Resolved] CUSTOM ARCHIVE.PHP and CONTENT.php

Home Forums Support [Resolved] CUSTOM ARCHIVE.PHP and CONTENT.php

Home Forums Support CUSTOM ARCHIVE.PHP and CONTENT.php

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1966018
    FunkyCss

    Hello There,

    I remember in older versions Generatepress had the get_template_part( content, etc.. )

    Now I notice that is tottaly different and I am really confused how it actually works? ( generate_do_template_part( ‘archive’ ); )

    What I need to do is

    To create a CPT of displaying archives ( Created a custom taxonomy and copied the archives.php )

    Now I need to customise the loop content of this CPT by copy the content.php and renaming products-content.php

    I believe I am right till here.

    The issue is that I dont understand where to hook that products-content.php as the templating is a bit different.

    #1966034
    David
    Staff
    Customer Support

    Hi there,

    in your custom archive template you can switch this line:

    https://github.com/tomusborne/generatepress/blob/2c7c8a76d3b58b0b97e82b3a7a5ebf022a1ddfbe/archive.php#L40

    to:

    get_template_part( 'content', 'your-cpt-content-slug' );

    #1968192
    FunkyCss

    Hi David,

    Yes this is with the old way and it actually works.

    I am curious tho how works the new one, there is any documentation for this ? Just curious

    Thank you once again.

    #1968195
    David
    Staff
    Customer Support

    Its just a custom function.
    So you can leave it as is for example:

    generate_do_template_part( 'your-cpt-content-slug' );

    It will return exactly this:

    get_template_part( 'content', 'your-cpt-content-slug' );

    #1968204
    FunkyCss

    OK thank you a ton !

    #1968208
    David
    Staff
    Customer Support

    You’re welcome

    #2519884
    Alberto

    Hello,
    I think I’m in the same case as FunkyCss but with standard WP categories: I need to make a custom html markup for the post in archive (or category) but I don’t quite understand how I have to do it.
    Could you explain me wich is the .php file I must edit or create?

    Thanks in advance

    #2519997
    David
    Staff
    Customer Support

    Hi there,

    are you wanting to modify the HTML of the standard archive pages ? Or is it for a specific post type or taxonomy or… ?

    #2520557
    Alberto

    Hi David
    Thank you for replying.
    It’s for standard archive pages. In fact, for standard category.

    Regards

    #2520628
    Ying
    Staff
    Customer Support

    Hi Alberto,

    Take a copy of content.php file from the parent theme, paste it into your child theme folder, then you can edit the file in the child theme.

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