• Resolved resunoiz

    (@resunoiz)


    I need to modify the functions.php on my father theme in order to change “Continue reading” link and “view more text”.

    Here’s the original code:

    function bavotasan_front_page_render() {
    	global $wp_query, $paged;
    	?>
    	<?php while ( have_posts() ) : the_post(); ?>
    		<?php if ( is_front_page() ) { ?>
    		<div class="item">
    			<figure class="effect-julia">
    				<?php
    				if ( has_post_thumbnail() )
    					the_post_thumbnail( 'home' );
    				else
    					echo '<img src="' . BAVOTASAN_THEME_URL . '/library/images/no-image.jpg" alt="" />';
    				?>
    				<figcaption>
    					<h2><?php the_title(); ?></h2>
    					<div>
    						<p><?php echo wp_trim_words( strip_shortcodes( get_the_excerpt() ) , 10 ); ?></p>
    						<p class="more-link-p"><?php _e( 'Continue reading <span class="meta-nav">&rarr;</span>', 'destin' ); ?></p>
    					</div>
    					<a href="<?php the_permalink(); ?>"><?php _e( 'View more', 'destin' ); ?></a>
    				</figcaption>
    			</figure>
    		</div>
    		<?php } else { ?>
    			<?php get_template_part( 'content', get_post_format() ); ?>
    		<?php } ?>
    	<?php endwhile; ?>
    	<?php
    }
    
    add_action( 'wp_head', 'bavotasan_styles' );

    I tried with remove_action as read on varios places but I don’t know where am I wrong. Every time I get that error:

    “Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, ‘altered_bavotasan_styles’ was given in /web/htdocs/www.crea11.it/home/studiocrea/wp-includes/plugin.php on line 496”

    and here’s the child functions.php commands. what am I mistaking?

    function dequeue_bavotasan_styles() {
      remove_action( 'wp_head', 'bavotasan_styles' );
    }
    add_action('after_setup_theme', 'dequeue_bavotasan_styles');
    
    function altered_bavotasan_front_page_render() {
    	global $wp_query, $paged;
    	?>
    	<?php while ( have_posts() ) : the_post(); ?>
    		<?php if ( is_front_page() ) { ?>
    		<div class="item">
    			<figure class="effect-julia">
    				<?php
    				if ( has_post_thumbnail() )
    					the_post_thumbnail( 'home' );
    				else
    					echo '<img src="' . BAVOTASAN_THEME_URL . '/library/images/no-image.jpg" alt="" />';
    				?>
    				<figcaption>
    					<h2><?php the_title(); ?></h2>
    					<div>
    						<p><?php echo wp_trim_words( strip_shortcodes( get_the_excerpt() ) , 10 ); ?></p>
    						<p class="more-link-p"><?php _e( 'Cooontinue reading <span class="meta-nav">&rarr;</span>', 'destin' ); ?></p>
    					</div>
    					<a href="<?php the_permalink(); ?>"><?php _e( 'Viooooew more', 'destin' ); ?></a>
    				</figcaption>
    			</figure>
    		</div>
    		<?php } else { ?>
    			<?php get_template_part( 'content', get_post_format() ); ?>
    		<?php } ?>
    	<?php endwhile; ?>
    	<?php
    }
    
    add_action( 'wp_head', 'altered_bavotasan_styles' );
Viewing 12 replies - 1 through 12 (of 12 total)
  • Maby im missunderstanding your question here but.
    functions.php in child theme.
    Your child theme will import parents functions.
    This means you need to copy over any of the PHP code to still have it active in your new theme.
    The functions.php in childthemes are in many cases completely empty.

    Maby thats what you can try, empty your childthemes functions.php
    And se if that helps.
    Unless you have been writing specific code in functions.

    And are you shure that the “read more” is in your functions.php?
    If we are talking about changing the text i would check index.php
    And look for
    <?php the_content(); ?>
    But on the other hand, i dont know if its just the text or something else that you want to change.

    Moderator keesiemeijer

    (@keesiemeijer)

    You are removing the action for bavotasan_styles while I think you want to remove the action for bavotasan_front_page_render.

    Is the function bavotasan_front_page_render also called with an action?

    Thread Starter resunoiz

    (@resunoiz)

    thans for fast response.

    the firs code block was from father functions.php, the second was the on I put in the child functions.php in order to change “continue reading” text.

    Yes keesiemeijer, what I need to change is effectively in bavotasan_front_page_render. how can I see if is it called with an action?

    Moderator keesiemeijer

    (@keesiemeijer)

    Can you paste the parent file contents with the ‘bavotasan_front_page_render` function in it in a pastebin and post the link to it here.

    Thread Starter resunoiz

    (@resunoiz)

    https://pastebin.com/E47shrag

    hope i’ve made it right ??

    Moderator keesiemeijer

    (@keesiemeijer)

    Is that all there is in the parent functions.php file?

    Thread Starter resunoiz

    (@resunoiz)

    sorry, didn’t get that.

    I copied what I found in functions.php for that function…

    Moderator keesiemeijer

    (@keesiemeijer)

    Sorry, I need to see the whole functions.php file.

    Thread Starter resunoiz

    (@resunoiz)

    sure!
    https://pastebin.com/i7ck0Rs3

    pasted in the same site you linked me, right?

    Moderator keesiemeijer

    (@keesiemeijer)

    The function is called for theme support of infinite scroll. You can remove the support and add it back yourself (in your functions.php)

    Try this as your child functions.php
    https://pastebin.com/YYCjAijL

    Thread Starter resunoiz

    (@resunoiz)

    it works! ??

    Moderator keesiemeijer

    (@keesiemeijer)

    Good to hear ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘override functions.php in child theme: where am I wrong?!?’ is closed to new replies.