Site logo

[Resolved] How to create style archive.php and single.php for a template directory

Home Forums Support [Resolved] How to create style archive.php and single.php for a template directory

Home Forums Support How to create style archive.php and single.php for a template directory

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2223499
    Wim

    Hi team,

    I have a question regarding how to approach the the implementation of a real estate plugin with it’s own archive, functions, loop and single.php file, located in a sub directory of the theme. I hope I explain in well enough, but here goes.

    This real estate plugin come with it’s own php theme files – as mentioned above – which are located in a directory inside my child theme (child of GeneratePress). These files take care of displaying the properties and are meant as an example to style my own. As I understand correct, this real estate module looks for the files in this directory automatically.

    Now I would like to style the pages within WordPress as any other page. Is this something that is possible, or do I need style these page myself.

    Kind regards, Wim

    #2223524
    David
    Staff
    Customer Support

    Hi there,

    thats correct WP’s template hierarchy will check the Child Theme first, so if they are correctly located then they should be used.

    Now GP won’t know the templates exist, and therefore styling those templates will either come down to:

    a. Using custom CSS or any hook APIs the plugin developer provided.
    b. editing the PHP Templates to fall in line with GPs – you could try comparing its single.php with ours:

    https://github.com/tomusborne/generatepress/blob/master/single.php

    #2223557
    Wim

    Thx for the quick response David. It is a bit more clear to me now.

    The theme files I was talking about are not in the root of the child theme though. They are located within a directory within the child theme. They seem to be used only for a custom post type the real estate plugin creates.

    So for the site in general, the default theme files of GeneratePress will be used.

    What I want to accomplish is to style these plugin theme files, according to GP settings. To be more precise, mainly the structure part of styling. So for instance if I choose in GP to change the with of the site container from 1200 to 1100, these changes are also noticeable for the plugin theme pages.

    #2223851
    David
    Staff
    Customer Support

    You would need to create for example a single.php that is a hybrid of GPs single.php and your plugins.
    see here:

    https://github.com/tomusborne/generatepress/blob/a3ce1712ab1cc705fed577fad8fa9ea8c04d5d20/single.php#L24-L32

    I highlight the loop in GPs single.php. The loop is where the relevant content template is called.
    Everything around the loop provides the pages structure.

    So it may be a case of using our template and replacing the loop with the plugins template.

    As a note – the way GP works for displaying the content is the generate_do_template_part' function in side the loophttps://github.com/tomusborne/generatepress/blob/a3ce1712ab1cc705fed577fad8fa9ea8c04d5d20/single.php#L29

    Which in this case returns our content-single.php

    https://github.com/tomusborne/generatepress/blob/master/content-single.php

    Not sure if that helps 🙂

    #2225100
    Wim

    Thanks David, I will look into your suggestion.

    #2225226
    David
    Staff
    Customer Support

    You’re welcome

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