I browsed through the suggested posts, and couldn’t find anything that was exactly answering my question. I apologize in advance if I’m reposting something obvious here, but there you have it.
I want to make a theme that makes it easy to hand-craft my (single page) posts as if I was living without a CMS at all. I do still want these posts to have the benefits of being archived, perma-linked, getting stats, using the media library and so forth from WP, but I want the authoring flow to be as if I started with a blank folder with a “index.html”, a “style.css” and a “scripts.js” file every time.
It’s been a while since I was working with WP, but here’s a sort of a checklist of stuff I want.
- The ability to “toggle” which parts of the loop are visible and which aren’t. (“toggle date, toggle post title, toggle footer, toggle footer elements, toggle comments link, etc”.)
- The ability to specify in the WP authoring space a CSS file and a JS file specific to that post. I guess entering this into textareas would suffice as well.
- Uploading images for backgrounds and other design-related images to a place that’s coupled to the post directly rather than just uploading them to a folder via FTP and using the direct links.
I’m not sure I’m communicating very well here, but imagine that my motivation is that when I create a post I want full control over how that post looks (again, in single post view) as if I’d designed it from scratch, but I want to take advantage of the handy mark-up that WP creates and the content management abilities of WP.
If you do understand what I’m getting at I’d love some pointers to where to start in form of links to themes that incorporate some or several of these features, advice on how to go about letting each post have a dedicated folder with belonging styles, scripts and images without making a godawful mess and so forth.
If you don’t understand what I’m talking about I’d really love for you to help me out by telling me where I’m being fuzzy so that I can clarify my ideas a bit.
Thanks in advance,
Martin
This shouldn’t be very difficult.
WPs Template Hierarchy should get you started on what page loads every time.
You’ll probably be best maintaining minimal header.php and footer.php and working your logic on single files, named as per the Hierarchy.
Then, head to add_meta_box() and update_post_meta() to implement those selectors for css and js and also any switches to toggle.
Then, it’s about the best use you can make of the Conditional Tags to dinamically find out which content you’re loading and fetch the right files for it.
I don’t develop themes, but when building a site I achieve this kind of setup you describe using the plugin Advanced Custom Fields.
With it, I can hook custom meta boxes (text, image, checkboxes, dropdowns, etc) into posts, pages and CPTs, and fine tune their appearance according to page-template, categories and other conditionals. It can also hide the default WordPress boxes and meta boxes.
Based on this custom fields, I’m able to render the front pages and posts with great detail.
That said, there’s this class (Custom Metaboxes and Fields for WordPress), for theme inclusion, that may be able to give you the same functionality. I haven’t used it, because ACF gives me that and it’s theme independent.
You can also study how ACF works. In this answer, I’m using his code as base to enable/disable the visibility of the Featured Image meta box according to the selected page template.