Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6189553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:26:03+00:00 2026-05-24T02:26:03+00:00

following the tutorial at http://josephscott.org/archives/2010/03/database-powered-css-in-wordpress-themes/ i am trying to use wordpress’ parse_request function to

  • 0

following the tutorial at http://josephscott.org/archives/2010/03/database-powered-css-in-wordpress-themes/ i am trying to use wordpress’ parse_request function to add some php-driven CSS… mostly style options set in my theme’s options panel. i am aware that my code looks a little different from the author’s, but i tried it his way already. i can add the

function kia_wp_head() {
  wp_enqueue_style('dynamic', get_bloginfo('stylesheet_directory') . '/admin/ . '?my-custom-content=css');
}
add_action('wp_print_styles', 'kia_wp_head');
//this shows up properly enqueued but when i click on it in source it just brings up a directory listing for the admin folder


function my_custom_wp_request( $wp ) {
    if( isset($_GET['my-custom-content']) && $_GET['my-custom-content'] == 'css'  ) {

        # get theme options
        header( 'Content-Type: text/css' ); ?>

body {
    background-color: <?php echo 'red'; ?>
}

<?php
        exit;
    }
}
add_action( 'parse_request', 'my_custom_wp_request' );

but since the background never turns red, I am either not implementing this properly or the tutorial is missing a critical step. i’ve also tried the other method of putting the dynamic css in its own custom-css.php file, which is my ultimate goale, but i was just trying to see if i could interact with the parse request function properly:

function my_custom_wp_request( $wp ) {
    if (
        isset($_GET['my-custom-content'])
        && $_GET['my-custom-content'] == 'css'
    ) {
        # get theme options
        header( 'Content-Type: text/css' );
        require dirname( __FILE__ ) . '/custom-css.php';
        exit;
    }
}
add_action( 'parse_request', 'my_custom_wp_request' );

here i’m not sure what dirname( FILE ) means exactly, but i have also tried using a hardcoded path and that didn’t work either.

so how do i get parse_request to see my php-driven stylesheet?

/* EDIT FOR SOLUTION */

basically this doesn’t work w/ wp_enqueue_style

wp_enqueue_style(‘dynamic’, get_bloginfo(‘stylesheet_directory’) . ‘/admin/ . ‘?my-custom-content=css’);

but DOES work as described at josephscott.org by inserting the style tag directly into the head

. ‘/admin?my-custom-content=css”>

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:26:03+00:00Added an answer on May 24, 2026 at 2:26 am

    i found that it doesn’t work w/ wp_enqueue_script. it does work as written in the tutorial by manually adding the script tag to the header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.