• I want to put up posts that have their own defined style. I have created classes in the stylesheet and am calling them using html tags in posts. It does not seem to work.

    Any suggestions?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Are these new styles in the CSS above styles which could override them ?

    Thread Starter sumeetsingh

    (@sumeetsingh)

    Yes.. I created a CMS using WordPress and now I want individual styles for each of the categories like about, home etc.
    For this, I created different styles/classes in the stylesheet that I want to use.
    These will override the existing style for posts or entries.

    The variable $cat and $single can be used for checking whether you are in a permalink page, category page or the main page. You can create a conditional statement and include the desired stylesheet that way.

    Thread Starter sumeetsingh

    (@sumeetsingh)

    thanks for the reply . Unfortunately this is the first time I am using something in PHP and I would like it if there is something in wordpress i can manipulate after reading docs and stuff. Is there any example that you can help me with?

    Thread Starter sumeetsingh

    (@sumeetsingh)

    bump..

    Thread Starter sumeetsingh

    (@sumeetsingh)

    I think I got what I wanted to do. After much looking at PHP and some of the threads, I added the following code to the index.php and created each of the css layout files as I wanted to.

    <?php
    switch($cat) {

    case “1”:
    print “<link rel=’stylesheet’ href='”;
    echo get_settings(‘siteurl’);
    print “/wp-layout1.css’ type=’text/css’ media=’screen’/>”; break;

    case “2”:
    print “<link rel=’stylesheet’ href='”;
    echo get_settings(‘siteurl’);
    print “/wp-layout2.css’ type=’text/css’ media=’screen’/>”; break;

    case “3”:
    print “<link rel=’stylesheet’ href='”;
    echo get_settings(‘siteurl’);
    print “/wp-layout3.css’ type=’text/css’ media=’screen’/>”; break;

    default:
    print “<link rel=’stylesheet’ href='”;
    echo get_settings(‘siteurl’);
    print “/wp-layout1.css’ type=’text/css’ media=’screen’/>”; break;}
    ?>

    Is this working for you? I have just a few places where I want to add more styles to the post and I really don’t want to:

    1) include them in the style sheet (why add more unnessary stuff when this is occassional)

    2) add if/then statements to the index.php when these are rare occassions

    I can set up static pages for these (in v1.5) but there must be an easier way.

    So what are some other choices?

    bump

    I’m really getting desperate about including stylesheets in posts. I can just pile in a lot of one-off css selectors into one large style sheet, but I’d really love to optimize this. I can go through and hard code the styles into the tags, but this doesn’t always work for every css reference.

    Anyone come up with a way of getting stylesheets into posts?

    Given the size of css files, the speed that they download, and the options offered by the Optimiser ( https://flumpcakes.co.uk/css/optimiser/ ) I would put what you need into the CSS for the main site.
    Like you I don’t agree with unnecessary code, but sometimes just accepting that the workround is more painful than a few K in the CSS just has to be done.

    Run your CSS through the optimiser a few times, see what it’s like ?

    Thread Starter sumeetsingh

    (@sumeetsingh)

    Lorelle i apologise for not getting back on the thread.. was away for sometime.
    I also had to include just one or two tags in my posts so that some of the images and content is shown the way i want them to.
    Unfortunately using 1.2 I tried everything, read all parts of docs, went through static plugins but couldnt achieve this. So i thought of adding little more code and styles to achieve this. Workaround at that time for me was a bit more important than finding something optimised .. ?? I can understand your frustration on this..
    btw are you tryin to use this as CMS?( just a question..)

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Allowing use of stylesheet in posts’ is closed to new replies.