Matthew Simo
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Custom Fields in a dynamic css file using .phpSo, after some extensive testing I’ve pinpointed where my code is breaking down. I must say, I didn’t expect it at all (it was the last thing I tested..)
So in the header I’m using:
$css = get_post_meta($post->ID, 'post_css', true); if(!empty($css)){?> <link type="text/css" rel="stylesheet" href="https://localhost:8888/wordpress/wp-content/themes/simo-portfolio&blog/post-css.php?post-id=<?php echo $post->ID; ?>" media="screen" /> <?php } ?>
And the code I’m using in post-css.php is:
<?php header('Content-type: text/css'); ?> <?php $id = $_GET['post-id']; echo get_post_meta($id, 'post_css', true); ?>
As far as I can tell, the get_post_meta function isn’t working. Like, just flat out isn’t working. I tested each line prior to this and the values were being passed successfully. I used a constant in place of $id, and nothing. I assigned get_post_meta to another variable, attempted to echo the new variable, and nothing.
So, my new question, is there a function call I need to make to gain access to this function? I don’t consider myself a php developer so I’m halfway clueless here. The post-csss.php file is sitting in my theme folder, I assumed that is all I needed to do to gain access to all of the lovely WP functions. Anyone know why the get_post_meta stopped working? Or an idea on how to gain access to WP functions that aren’t really part of the WP architecture? Or even better, how to get this working?
Sorry for the super long post, but I do appreciate any insight!
Thanks,
Matthew SimoForum: Themes and Templates
In reply to: Custom Fields in a dynamic css file using .phpbump
Forum: Themes and Templates
In reply to: Custom Fields in a dynamic css file using .phpI’m using absolute paths as this is a test on a local install. The CSS link looks like a normal css <link>: I basically check to see if there is a $key “post_css” and if there is I assign the value to $css. If $css is NOT empty I put in the <link> to the post-css.php file that is in my child theme directory.
$css = get_post_meta($post->ID, 'post_css', true); if(!empty($css)){?> <link type="text/css" rel="stylesheet" href="https://localhost:8888/wordpress/wp-content/themes/simo-portfolio&blog/post-css.php" media="screen" />
In the post-css.php file I’ve got the following code:
<?php header("Content-type: text/css"); $css = get_post_meta($post->ID, 'post_css', true); echo $css; } ?>
Any ideas?