Which template files do i need to build Directory into my theme?

I am struggling to build Directory into my theme. What is the structure of the template files?
The template files in the default theme are arranged differently to those in ui-front/general...?
I have tried adding page-listings.php & archive-listings.php to my theme but neither of them get loaded.

Please can you tell me how to integrate this and build my own template files, telling me which ones i need to create (there is no real documentation for this)

Thanks

  • Ash
    • WordPress Hacker

    Hello @PoshWeb

    I hope you are well today and thanks for asking the question.

    If you use listing post type then the template name should be single-directory_listing.php and archive-directory_listing.php

    I have tried adding page-listings.php & archive-listings.php to my theme but neither of them get loaded.

    This two page will only load if the page slug is listings.

    The template files in the default theme are arranged differently to those in ui-front/general

    Yes, I think so. You can follow the default one as it seems a complete theme.

    Please let me know if you need more help.

    Cheers
    Ash

  • PoshWeb
    • Design Lord, Child of Thor

    Ok, so i still can't get it to work. I have created a simple template to override the basic function so i can see when it works...and it doesn't :slight_frown:

    I have tried archive-directory_listing.php and taxonomy-listing_category.php and neither of them are getting loaded.

    Any ideas?

  • Ash
    • WordPress Hacker

    Hi there

    Would you please send me your login and ftp details so that I can try to setting up the pages and once it is loaded you can put your desired code?

    To send details, please use our contact form: https://premium.wpmudev.org/contact/

    Select: I have a different question
    Subject: Attn-Ash
    Details: Send all required details (admin info and/or ftp details) with a link of this thread, so that I can track.
    Also post a note here once you send the info.

    I will be happy to take a look :slight_smile:

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    I have uploaded three files in your theme file. You just remove the beginning underscores and write your code in there.

    ____single-listing.php => individual listing page
    ____archive-listing.php => all listing page
    ____page-my-listing.php => my listing page

    Please let me know if you find this is helpful, or if you have any further questions.

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    I just checked again in my test site. I made a mistake though. The file name should be

    single-listing.php => individual listing page
    archive-listings.php => all listing page
    page-my-listings.php => my listing page

    And it works fine in my site.

    Would you please check with default WP 2012 theme and let me know?

    Cheers
    Ash

  • Ash
    • WordPress Hacker

    This is really strange, and I am out of idea! :slight_frown:

    In your site custom template for single listing is working.

    I have set exactly same settings as yours and it worked for me! Check screenshot.

    Let me get help from one of my colleague @Jack Kitterhing for this issue.

    Cheers
    Ash

  • Jack Kitterhing
    • Code Norris

    Hi there @PoshWeb,

    Hope you're well today and thanks for your question.

    Sorry to see of the issues your having here, our lead developer of "Directory" covers this in his post here https://premium.wpmudev.org/forums/topic/what-file-pulls-the-page-template-in-the-directory-plugin#post-476924 :slight_smile:

    Also at the top of that thread, there's a link to a great thread on customizing the Directory display/output :slight_smile:

    Thanks!

    Kind Regards
    Jack.

  • Ash
    • WordPress Hacker

    Hi @Jack Kitterhing

    Thanks for your valuable input. I have tried exactly same, and it worked for me too. But FYI, when I tried in his server, it worked for single and page listing but not archive listing.

    Also, I am looking forward to hear from @PoshWeb if he can do something with the suggested thread.

    Cheers
    Ash

  • PoshWeb
    • Design Lord, Child of Thor

    Ok. I have deactivated all my plugins and reverted to 2012 theme. This doesn't work!
    According to Arnold in the other thread, the template files loaded are in ui-front/general - there isn't an archive file in there anyway?

  • Arnold
    • El Macho WP

    The files in /ui-front/general/ generate Content Only. When you use a substitute template like archive-listings.php you're on your own as far as what is output. You can use the code in /ui-front/general/ as a guide but you have to figure out what to display.

    Here's what I did to test the archive template.

    1. Go to 2012 theme directory

    2. Make a copy of "archive.php" in the same directory and rename it to "archive-listings.php"

    3. In the new file I added

    <h2>This is archive-listings.php</h2>

    just below the </header> tag in the template.
    Tried clicking Listings in the browser. and I see the "This is archive-listings.php". That proves it's picking up the file.

    After that modify to do what you want to do.

    If that doesn't work, are you using buddypress or similar add-ons?

  • PoshWeb
    • Design Lord, Child of Thor

    Hi Arnold,

    Thanks for stopping by...and a Happy New Year to you!

    I am using BuddyPress, but i deactivated it while i troubleshoot this issue.

    For the avoidance of any doubt or confusion, i will try to list everything below so you can understand my issue:

    My permalinks are set to /%postname%/

    I have CPT directory_listing with custom slug "directory"
    I have custom taxonomy listing_category with custom slug "city"

    I want to build templates for individual listings that appear as:
    mywebsite.com/directory/this-is-my-listing/

    and archive pages that appear like:
    mywebsite.com/city/cambridge/

    I used the archive-listings.php that Ashok provided and added a simple <p>message</p> to check if that file was being used, but it wasn't - even on 2012 with all plugins deactivated.

    Ashok has the keys to my website if you need to go and have a look around!

    Thanks
    John.

  • Arnold
    • El Macho WP

    First problem I see is that the Archive slug and the Permalink slug are both set to "directory". The system has no way of telling whether you want an archive or a single entry.

    The two slugs must be different. Usually the Archive slug is the plural of the rewrite slug. /directories/ and /directory/ Confusing since Directory is already collective. One of the reasons we used /listings/ and /listing/

    As far as your custo templates. You are using the Commons in a Box template which does not follow the Wordpress standards. For example in the archive.php they use

    infinity_get_template_part

    instead of Wordpresses

    get_template_part.

    So the standard Wordpress rules don't apply. You will need to contact the theme author to find out how it handles child themes.

    theoretically the new archive name would be "taxonomy-listing_category.php"
    Your theme applies a filter that forces it to page.php. I tested it on your site. They are programming around the Wordpress standards.

  • PoshWeb
    • Design Lord, Child of Thor

    Hi,

    Thanks Arnold. I have only just installed the Cbox theme to test it out - i was using Genesis before when i asked the question (and also tried on 2012 standard)..so maybe i will switch back!

    So you are saying that if i change the archive slugs, then the file responsible for the output of page mysite.com/city/cambridge/ would be taxonomy-listing_category.php correct?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.