1

Reactor Theme is built on Zurb Foundation and is here - I think it's quite good.

The theme I am replacing used the featured image in the posts or blog page but not in the post itself. Reactor calls the image in both. I want to try and change that so that I can have the featured image on the blog page and not in the post. It causes a problem because I usually use the image in the post and use that for the blog page.

The Reactor theme uses lots of includes, functions, hooks and all that fancy shizzle so I am finding it complicated. I think I have worked out that this is calling in the featured image:

function reactor_do_standard_thumbnail() { 
$link_titles = reactor_option('frontpage_link_titles', 0);

if ( has_post_thumbnail() ) { ?>
<div class="entry-thumbnail">
    <?php if ( is_page_template('page-templates/front-page.php') && !$link_titles ) { 
        the_post_thumbnail( 'thumb-150' );
    } else { ?>
                <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail( 'thumb-150' ); ?></a>
        <?php } ?>
    </div>
<?php }
}
add_action('reactor_post_header', 'reactor_do_standard_thumbnail', 4);

The full code for that is here on Git.

Am I correct in thinking that this bit of code is what is doing what I think it is? Can anyone give me a clue as to how I change this behaviour?

Thanks

1
  • But are you using a Child Theme? If not, simply modify the function and see what happens.
    – brasofilo
    Commented Oct 23, 2013 at 17:50

2 Answers 2

0

Callback

This is how "Reactor" hooks the callback

add_action( 'reactor_post_header', 'reactor_do_standard_thumbnail', 4 );

Backtrace

The function itself is hooked from where you linked

~/theme_root/library/inc/content/content-post.php

but this file is called by the class Reactor. This class/file is not included during the main callback hooked to after_setup_theme in the functions.php file on priority 10, but before that without a callback. And it gets instantiated right afterwards:

require locate_template('library/reactor.php');
new Reactor();

When the class gets instantiated and the __construct()or gets called, it hooks the callback that registers the callback for the default thumb on priority 14 on the after_setup_theme hook ... (FYI: in lame PHP 4 style).

add_action('after_setup_theme', array( &$this, 'content' ), 14);

Then the content() method does nothing else than including another file:

require_once locate_template('/library/inc/content/content-pages.php');

And this file is the one that actually attaches the default thumbnail here.

add_action('reactor_post_header', 'reactor_do_standard_thumbnail', 4);

Exchange

Now simply add the following in your CHILD THEME functions.php file.

/**
 * Remove the original callback, add in a new one
 */
add_action( 'after_setup_theme', 'wpse119843RemoveStandardThumbs', 20 );
function wpse119843RemoveStandardThumbs()
{
    // Removes it for posts AND pages. If you only want posts, use is_single()
    if ( is_singular() )
        remove_action( 'reactor_post_header', 'reactor_do_standard_thumbnail', 4 );

    add_action( 'reactor_post_header', 'wpse119843AddCustomThumbs' );
}
/**
 * The callback that formats the new output
 */
function wpse119843AddCustomThumbs()
{
    $link_titles = reactor_option( 'frontpage_link_titles', 0 );

    if ( has_post_thumbnail() )
    {
        ?>
        // REFACTOR REACTOR
        <?php
    }

}

NOTE

To preserve your changes, use a Child Theme. When you take a closer look at the site, then you'll see that there already exists one.

1
  • OMG! That is awesome help. I will have to wait to tomorrow to try it but you seem to have explained it brilliantly. I'll get back to you when I get it implemented. Thanks again.
    – martcol
    Commented Oct 23, 2013 at 22:09
0

This is what cracked it:

function reactor_do_standard_thumbnail() { 
$link_titles = reactor_option('frontpage_link_titles', 0);  
if ( has_post_thumbnail() ) { ?>
<div class="entry-thumbnail small-4 column">            
<?php if ( is_page_template('page-templates/front-page.php') && !$link_titles ) { 
the_post_thumbnail( 'thumb-150' ); ?>
<?php } elseif ( is_single()){ ;?>
    <?php } else { ;?>
            <a href="<?php the_permalink(); ?>" rel="bookmark"     title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('thumb-150');     ?></a>
<?php } ?>
</div>
<?php }
}
add_action('reactor_post_header', 'reactor_do_standard_thumbnail', 4);

Your Answer

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

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