worpdress custom field
If I understand you correctly, you are trying to add a field to allow someone to set a value within a post that will be used in CSS when displayed on the post page? If so, first you will need to create a custom field. It's pretty straight forward, but here's a quick tutorial on field creation: https://www.advancedcustomfields.com/resources/creating-a-field-group/
Once you have that field created, you'll want to pull it in on the post page, so single.php would be the file to bring it in. You can access the value of that field from within single.php using something like the following (swapping field_name with the name of your field):
<?php the_field('field_name'); ?>
If you want to use the CSS inline, you could do something along these lines:
<div style="<?php the_field('field_name'); ?>">Your content here.</div>
Hopefully this clarifies things a bit for you.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now