Home Forums Front-end Issues Shortcode in themes content template


Shortcode in themes content template

  • Hey!

    Currently I am building a new website with several custom post types and taxonomies with custom fields. In one special case I want to print out 1 to 5 stars depending on which number you chose in a custom field. (radio buttons, 1 2 3 4 5).

    I can achieve this via a custom php template for my custom post type.

    $starNumber = get_field(‘sternekategorie’);

    for($x=1;$x<=$starNumber;$x++) {
    echo ‘<i class=”fas fa-star”></i>’;

    To keep it simple I did not use custom php templates in my child theme, but built the templates via my theme. (content templates) I can then just build the grid in the backend and put my fields where I want. But if I have to add php code it does not work.

    Do you think that would be somehow achieveable via shortcodes? [acf field="{$sternekategorie}"] I saw some examples in the forum. I would be glad to just keep all content templates in the theme as I only need this this function for one special case.

    Thanks for your help!

  • Using the ACF shortcode depends on whatever you’re using for a theme supporting shortcodes where you want to use them and also what type of ACF fields you want to show. Not all ACF field types are supported by the acf field shortcode.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.