Take the 2-minute tour ×

I'm using advancd-custom-fields plugin and I'm about to modifiy my acrhive content page that is shown frontend. I use the file personnel-archive.php (because the custom post type used is personnel) in my theme in that works ok:

Beginning of this file looks like:

<?php get_header(); ?>


            <h1 class="personnel"><?php the_title(); ?></h1>

            <div class="entry">  
                <?php echo image_personnel(get_the_ID());?> 
                <?php the_content('<p class="serif">L&auml;s resten &raquo;</p>'); ?>

                <?php wp_link_pages(array('before' => '<p><strong>Sidor:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>

I my functions.php I have made this function:

function image_personnel($post_ID) {
    $post_type = get_post_type( $post_ID );
    $content = '';

    //If custom type for shown post is personnel, then show image first
    if ($post_type == 'personnel') {

        $picture_personnel = get_post_custom_values('picture_personnel', $post_ID);
        if ($picture_personnel) {
            $image_fields = get_field('picture_personnel');                                
            $url_image = $image_fields['url'];
            $alt_image = $image_fields['alt'];
            $title_image = $image_fields['title'];
            if (strlen($alt_image)>0) {
                $title_image = $alt_image;
            else {
                $alt_image = $title_image;
            $content = '<img src="' . $url_image . '" alt="' . $alt_image . '" title="' . $title_image . '" />';   

    return $content;

I've basically just added a field "picture_personnel" to each personnel post and I want to show it in the content. Is it better to use filter for the_content? Or is it just a matter of taste?

share|improve this question
I personally think that if you are adding something to above, below, or to the side of the_content you don't need a filter but if you're adding something to the middle of the content or after the first paragraph you should probably use a filter. –  Howdy_McGee Jan 15 '14 at 17:28
In this specific case I would say this is completely matter of personal preference. –  Rarst Jan 15 '14 at 18:32
Thank you for your comments! I think those would qualify for an answer :-) –  bestprogrammerintheworld Jan 15 '14 at 18:33

Your Answer



Browse other questions tagged or ask your own question.