Passing WordPress info to php stylesheet (4 posts)

  1. TechDragon12
    Posted 4 years ago #

    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!

  2. michael.mariart
    Posted 4 years ago #

    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.

  3. TechDragon12
    Posted 4 years ago #

    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.

  4. Chip Bennett
    Theme Review Admin
    Posted 4 years ago #

    To answer this question, we'll need to see the code you're using...

Topic Closed

This topic has been closed to new replies.

About this Topic