Acquiring Info from an Excel File and then Importing into CSS

I’ve been doing some research for a while now and I haven’t come up with a straightforward solution.

While working off of a WordPress theme, I would like to implement a variable into my CSS document.

Read More

I understand this can be done through PHP and CSS Preprocessors.

However, I would like to take a CSV or XLS file, upload it to my server, and then have the CSS document recognize a cell or value within that file.

So ultimately, I’m looking to do the following:

a{
  font-size: @fontsize;
}

Where @fontsize in the CSV or XLS document is noted as:

20px;

I know WordPress also offers plugins to import CSV files, but from what it seems, it does not link them directly to the CSS documents.

Related posts

Leave a Reply

1 comment

  1. There’s no built-in way, but it’s easy to add in an internal style sheet. Write a function in functions.php to read the CSV file and extract the value. Then use the wp_head action hook:

    function head_css() {
        $output="<style>a {font-size: " . get_font_size() . ";}</style>n";
        echo $output;
    }
    add_action('wp_head','head_css');