I have a parent theme function as follows:

/* Display first image linked portfolio */
function ct_first_image_linked_portfolio() {
    $photo = ct_get_post_image();
    global $ct_options;
    global $post; ?>
        <div><?php the_post_thumbnail('large'); ?></div>
            <h3 class="marB0"><?php the_title(); ?></h3>
            <span><?php the_author(); ?></span>
            <a href="<?php the_permalink() ?>">View</a>
<?php }

I want to edit the markup that this function outputs. At first I thought I’d need to utilise some actions/filters to somehow filter the output. On closer inspection, the function doesn’t seem to be tied to any actions, and is simply called directly from a template file loop-portfolio.php:

while ( $query->have_posts() ) : $query->the_post(); ?>
    <li class="<?php ct_first_term(); ?> item col span_4">
        <?php ct_first_image_linked_portfolio(); ?>
<?php endwhile; ?>

So my question is, do I simply duplicate loop-portfolio.php into my child theme, and then change the function call to a different function? It seems like it would work but I’m checking there’s not a better way to do this. Thanks.

Read more here: Overriding a WordPress parent function that isn’t tied to any actions


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , ,

Wordpress related questions and answers: