0

I want to wrap a text with shortcode into the single.php file.

  • The shortcode is: [box type="note" align="aligncenter" ][/box] and
  • the code is:

    Διοργανωτής διαγωνισμού: <?php the_field('diorganwths_diagwnismou');?></br>
    Απαιτεί λογαριασμό Facebook: <?php the_field('apaitei_logariasmo_facebook');?></br>
    

How can i wrap the this php code so i can have it into the box as the shortcode orders?

1
  • If you show us all the code in single.php (by editing your question), we may be able to show you where the solution code can go. Commented May 7, 2013 at 21:43

1 Answer 1

0

You can use the load_value ACF filter:

function wpse0605_acf_load_field( $field ) {
    $field = '[box]' . $field . '[/box]';
    return $field;
}

// acf/load_field/name={$field_name} - filter for a specific field based on its name
add_filter('acf/load_value/name=diorganwths_diagwnismou', 'wpse0605_acf_load_field');
add_filter('acf/load_value/name=apaitei_logariasmo_facebook', 'wpse0605_acf_load_field');

The code can go into the theme's functions.php, or inside a plugin constructor.

2
  • @daldaeb, i tried it but it didn't work. Can you explain me more where do i have to insert the code because i want to use it in the single.php and not in the functions.php Commented May 7, 2013 at 9:57
  • @Charitos it seems you don't understand filters very well. Have a read of this. The Codex links at the end of article are also useful. Commented May 7, 2013 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.