Reputation: 11
I have to set up this function, which gets a value out of a custom field in a Wordpress article editor. It works and displays the price I inserted in the editor (e.g. 20,00)
BUT I can't style it using css.
<div class="price">
<p>
<?php echo '<div class="price">'. get_post_meta( get_the_ID(), 'price', true).'</div>'; ?>€
</p>
</div>
This is my css file:
.price { font-size:50px; color:#8e8e8e; }
Why does the css not apply to the code?
Upvotes: 0
Views: 2541
Reputation: 26380
CSS applied with PHP is no different than any other CSS. That's not the problem.
It's probably a matter of some other CSS with a more specific selector overriding your definition for .price
. Also, make sure that the path to your CSS file is correct and the code is loading. To diagnose this, load the script in your browser and use the code inspector to look at the div
with the .price
class. It will show you all the CSS applied to the element and you will be able to see if your .price
class rules are being applied and if they are overridden by another rule.
Get to know your code inspector - FireBug for FireFox is a valuable add-on, and Chrome has decent inspector built in. It's a powerful tool to figure out styling problems, among other things.
Upvotes: 1