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?

  • 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. – Charles Clarkson May 7 '13 at 21:43
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.

  • @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 – Charitos May 7 '13 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. – montrealist May 7 '13 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.