Support » Themes and Templates » Passing WordPress info to php stylesheet

  • Hello!
    I’m recent to WordPress (within a couple years), and new to Thematic (used by one of my clients). We are using a child theme within Thematic. It is mostly custom, and we use mainly pages for the site.

    I need to use a dynamic style sheet to change the background image and link colors depending on the page.
    I have been able to:
    enqueue the style sheet “wp_enqueue_style()” correctly.
    I have tested and verified the style sheet is working, using both basic css, and php functionality.

    I am stuck here:
    Getting “any” kind of id to be recognized by the stylesheet. pagename, slugname, id… any of these would be fine.

    I have tried various functions, arguments, variables in the header, functions page, and style sheet itself. I can get an output if they are in the header, or functions, but nothing at all… ever… is passed to the style sheet that I can use to identify these various pages.

    I feel like I’m missing something pretty easy, but can’t wrap my mind around it.

    Any help would be appreciated. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m not 100% sure (only because I can’t find where I’ve done that with a quick search) but I’m pretty sure that in the function that is registered with your enqueue stylesheet, you can add:
    global $post;

    If you add that right at the top of the functions code then you should be able to get the current post/page that is being used.

    Thanks, (I just tried it again), but this was one of the things I have tried previously. It seems like the page is isolated from the rest of WordPress. What is written in the file is being called by each page, but the file is not able to retrieve the values of variables, functions or classes from WordPress.

    Chip Bennett


    Theme Review Admin

    To answer this question, we’ll need to see the code you’re using…

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Passing WordPress info to php stylesheet’ is closed to new replies.