• I want to write (or have written) a wordpress plugin to manage tag-slug.php and cat-id.php templates so I don’t have to do it manually anymore. I “do not” want to store the data in the database, I want to actually create, list, and edit the physical files located in a theme dir from the plugin admin page.

    Is this feasible? Can this be done?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I have no idea but as a theme author and the maintainer of at least 7 WP sites (most of which have bespoke themes), I’d be pretty damn furious if a plugin amended any of the theme files without:

    1. Telling me first
    2. Explaining exactly what it will add and where
    3. Giving me the option to refuse.
    4. Also restores all theme files to their original state upon deactivation/uninstall.

    That aside, I’m not sure that this is such a good idea from a blog owner’s perspective, either. Every time they changed themes, they’d, presumably have to uninstall and re-install your plugin. Plus, it’s possible that theme authors might refuse support if the plugin had altered theme files – which could be a big problem if you’d just paid for a premium theme.

    What’s the problem with storing the data in the wp-options table?

    Thread Starter jtpratt

    (@jtpratt)

    @esmi – thanks for the reply. This wouldn’t amend any of a theme’s original files at all, it would create new ones.

    Let me explain the problem.

    Scenario: you have a WP site with 10 categories and 50 tags. You would like to take advantage of those pages by adding original content and possibly monetize particular ones with specific ads by category or tag. By creating a cat-id.php or tag-slug.php file (based on your index.php or single.php) and placing it in your theme dir, that file will be get served as the theme page for that particular tag or category page.

    I guess that you “could” store the specific content for a cat or tag page in the db, but I didn’t want an “additional” db query. I mean a WP page is already getting “the_content” for the post/page anyway, and the plugin would have to grab the specific cat/tag content and post it before the regular content (double lookup).

    But I do now see what you mean about “switching themes” – the tag/cat pages you created would have to be created again for a new theme.

    Any ideas? AFAIK there is no plugin out there that help to manage tag or cat pages at all.

    The concept of being to serve ads or specialised content on a category or tag basis is a great idea. I have at least 1 client who could definitely use that. All of the current ad-type plugins focus on posts – though 1 or 2 can be used in conjunction with an intelligent tag or template file to serve appropriate ads. But it’s still all rather manual and a bit of a drudge.

    With regard to the switching themes issue, I suppose it depends upon how/when plugin creates these new template files. If they’re created after completing, or updating, a configuration page, I can see that being a bit of a drag if you have to start again from scratch when you have a new theme. Could the plugin store some of it’s settings in the db? Maybe the list of tags and/or categories, for example, to reduce the amount of re-typing that has to be done?

    If it also stored the name of the current theme, perhaps you could build in an automated theme check at regular intervals? Then, if the theme has changed, you could display a visual alert that the config step needs to be re-done in a similar manner to plugin upgrades.

    Thread Starter jtpratt

    (@jtpratt)

    I think this plugin might be a bit more than I can handle programming wise, but it sure would be very useful.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can a Plugin open and edit template files?’ is closed to new replies.