2

I am creating wordpress that constists of many many custom styled static pages. Some has tables, some has text+iages etc. - so each page has almost unique style with some commonalityes, of course.

So I have a question - how to better style this. I have two options:

1) I create some static text, images, table etc. in wp-admin -> Pages; I will chante my style.css and create styles for each page

or

2) i will use advancec tinymce editor; I will create different custom styles for tables, images etc.; I will add text in wp-admin and user will see all custom styles and how pages look like. It seems that in this case use rwill be able to see custom page style. And also in this case the page will contains more tables (and not divs), as I think that this is easier to create in tinymce editor for user.

I have more than 40 custom styled pages. I wonder what is the best practice to style them so that user still will be able to modify text and some images.

EDIT:

Client have chosen to use Wordpress for this task and I do not have an option to choose any other CMS or other sollution.

There are some commonilities in all pages like menu, header, footer. All pages has heading, subheading with the same styling. Also bulletins and numbering are mostly with the same style. SO I have already done basic page structure.

However, if you imagine booklet, then you can imagine that every page has a bit different structure - some have three images in a row and that is it, some has text with 1 image, some has table, some has "image bar on the right side". Pages differ with content type and structure. Everythig could be achived with CSS, but I do not know what is better approach with WP when admin can edit the text.

Probably I can take make some groups of very similar pages, but not much and those groups will consist of 2-3 pages.

4
  • Wouldn't it be better to switch to (A) static HTML pages at all or (B) use some static site generator like Jekyll, Octopress, Phrozn, Hyde, etc.? I mean if you don't need the WP functionality then honestly, WP will mostly just stand in your way.
    – kaiser
    Jul 13, 2013 at 12:46
  • THis is not my page, but client wants to have wp Cms, probably, hw would like to change text later. There is some logic, because later some detailes of text could be changed.
    – renathy
    Jul 15, 2013 at 12:55
  • If so: Is there some predefined structure? Please update your question with something more accurate - or an example. Still, I wouldn't recommend using WP for this kind of task. Even a custom Silex based CMS would be better. Even if you use a static site generator, you can just use some sort of javascript/jQuery libraries like jEditable to edit text in place. Would be much easier. WP is hardly a good fit for this kind of task.
    – kaiser
    Jul 15, 2013 at 13:52
  • I have tried to update my question. I have to use WP and that is not an option.
    – renathy
    Jul 16, 2013 at 10:55

2 Answers 2

2

You can make each one into a custom Page Template, and either add the style block directly in the template, or conditionally load a stylesheet based on which template is in use. This will let you still use the editor to change the content of the page, but involves a lot of "one-off" page management.

I ran across this post that describes a way of using WordPress themes in pages outside the WP install itself. It may be useful to you: http://seb.so/adventures-in-wordpress/.

2
  • 2
    +1 for templates. For sites that I do that have a ton of different page designs, I just create a custom template for each one. It ends up a spamming the theme folder a bit, but that's not that big of a deal if you name them template-whatever.php, template-whatever2.php, etc. Jul 22, 2013 at 18:41
  • In wp 3.4+ page templates can be in a subfolder, helping keep theme better organized. However, with ton of page templates, the page template select menu in wordpress admin will be far from usable... and admin screen also slow down
    – gmazzap
    Jul 24, 2013 at 14:17
2

once I had a similar problem, and I solved it using a custom field and a bit of organization for files and folders.

First of all I created all css styles for my pages in a subfolder /css in my theme. Then, I created another subfolder, /pages and there I put all html structures for my pages.

Having, e.g.

My_Theme/css/style1.css, My_Theme/css/style2.css, My_Theme/css/style3.css

and the related

My_Theme/pages/style1.php, My_Theme/pages/style2.php, My_Theme/pages/style3.php

In my header.php I put

if ( is_page() ) {
  global $post;
  $page_style = get_post_meta($post->ID, 'page_style', true);
  if ( $page_style ) {
    // if a page style is defined, following code will include the file
    // in {TEMPLATEPATH}/css/{$page_style}.css
    // also define a constant to use later
    $src = get_template_directori_uri() . 'css/' . $page_style . '.css';
    wp_enqueque_style('page_style', $src, false, false, 'all');
    define('MYPAGESTYLE', $page_style);
  }
}

Finally, in my page.php file, I put

get_header();

// if a page style is defined, following two lines will include the file in
// {TEMPLATEPATH}/pages/{$page_style}.php
// in not, will include the file {TEMPLATEPATH}/page_content.php 

$part = defined('MYPAGESTYLE') ? 'pages/' . MYPAGESTYLE : 'page_content';
get_template_part($part);

get_footer();

Doing so handle one hundred or more custom page styles it's a cinch: just create the page and set the properly 'page_style' custom field. (Of course css and html must be created first...)

No custom page style defined? No problem, default will be used.

If there are parts that are shared among the different styles, extract and save those parts as separate files and then reuse them using @import in the styleXX.css and get_template_part() in styleXX.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.