I need to add a custom field to my article post but not sure how to add an additional class to it.
Currently the classes get pulled through like this <?php post_class($classes); ?>
.
However I need to add a custom field to this as well. To demonstrate ive added a class= but this doesnt work as class= is being added twice.
<?php post_class($classes); ?> class="<?php the_field( "size" ); ?>
So i need post_class and the_field to work together.
Thanks for your answers but I’ve found a simple way to do this
You can do this with two different way,
First:- Add following code in
theme's functions.php
file:This will add your class where
post_class
is called.Second:- Add this following code directly into your page:-
Hope this will help you little bit.
So why you could not do like this:
Because it is working like this: