I need to override this parent theme function:
add_action( 'travelify_after_post_content', 'travelify_next_previous_post_link', 10 );
/**
* Shows the next or previous posts link with respective names.
*/
function travelify_next_previous_post_link() {
if ( is_single() ) {
if( is_attachment() ) {
?>
<ul class="default-wp-page clearfix">
<li class="previous"><?php previous_image_link( false, __( '« Previous', 'travelify' ) ); ?></li>
<li class="next"><?php next_image_link( false, __( 'Next »', 'travelify' ) ); ?></li>
</ul>
<?php
}
else {
?>
<ul class="default-wp-page clearfix">
<li class="previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'travelify' ) . '</span> %title' ); ?></li>
<li class="next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'travelify' ) . '</span>' ); ?></li>
</ul>
<?php
}
}
}
With this in my child theme:
add_action( 'travelify_after_post_content', 'travelify_next_previous_post_link', 10 );
/**
* Shows the next or previous posts link with respective names.
*/
function travelify_next_previous_post_link() {
if ( is_single() ) {
if( is_attachment() ) {
?>
<ul class="default-wp-page clearfix">
<li class="previous"><?php previous_image_link( false, __( '« Previous', 'travelify' ) ); ?></li>
<li class="next"><?php next_image_link( false, __( 'Next »', 'travelify' ) ); ?></li>
</ul>
<?php
}
else {
?>
<ul class="default-wp-page clearfix">
<li class="previous"><?php previous_post_link_plus( array('order_by' => 'menu_order', 'loop' => true, 'link' => '%title' ) ); ?></li>
<li class="next"><?php next_post_link_plus( array('order_by' => 'menu_order', 'loop' => true, 'link' => '%title' ) ); ?></li>
</ul>
<?php
}
}
}
I can't figure out the proper way to override it in my child theme functions.php file.
I've tried this method:
if ( ! function_exists( 'travelify_next_previous_post_link' ) )
function travelify_next_previous_post_link() {
NEW FUNCTION HERE....
}
That just gives me a white screen.
What would I need to put in my child theme functions.php to replace that particular function?
You can try this
<?php
function child_remove_parent_function() {
remove_action( 'travelify_after_post_content', 'travelify_next_previous_post_link', 10 );
}
add_action( 'wp_loaded', 'child_remove_parent_function' );
?>
to remove the function to being load.
Or you can increase your child function priority Here is completed solution for you. http://code.tutsplus.com/tutorials/a-guide-to-overriding-parent-theme-functions-in-your-child-theme--cms-22623