Travelify Child Theme

Travelify is our the most popular WordPress theme with 200,000 downloads and counting. Lately we have received several support related questions about how to create Child Theme for Travelify (download). So we decided that things can be even simpler and we could provide a sample Child Theme.

Once activated this theme is not going to do anything and it is completely empty but it will allow you to create customization on top or original theme with ease.

Child Theme should be installed and activated like any other regular theme.

You can download it here.

Child Theme updated and no longer uses @import

This is great news. However, what happens when a file in a subfolder is modified ? For instance, I made a couple of changes in content-extensions.php located in travelify\library\structure. My new content-extensions.php is now located in travelify-child\library\structure but the changes do not seem to apply.

Is there any way to work around this ?

Thanks in advance for your answer.

@pinbeu

You are right and nothing is going to happen as these are not default WordPress theme files, so WordPress won’t recognize them unless you specially request that modified file via from functions.php file or otherwise.

That file might be tricky to modify but it is possible.

Since all function on that file are wrapped with ! function_exists you can copy/paste the entire function from that file to Child theme functions.php and modify it there.

For example to modify loop for search you would have to copy the entire function like this:

if ( ! function_exists( 'travelify_theloop_for_search' ) ) :
/**
 * Fuction to show the search results.
 */
function travelify_theloop_for_search() {
	global $post;

	if( have_posts() ) {
		while( have_posts() ) {
			the_post();

			do_action( 'travelify_before_post' );
?>
	<section id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
		<article>

			<?php do_action( 'travelify_before_post_header' ); ?>

			<header class="entry-header">
    			<h2 class="entry-title">
    				<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute();?>"><?php the_title(); ?></a>
    			</h2><!-- .entry-title -->
  		</header>

  		<?php do_action( 'travelify_after_post_header' ); ?>

  			<?php do_action( 'travelify_before_post_content' ); ?>

  			<div class="entry-content clearfix">
    			<?php the_excerpt(); ?>
  			</div>

  			<?php do_action( 'travelify_after_post_content' ); ?>

		</article>
	</section>
<?php
			do_action( 'travelify_after_post' );

		}
	}
	else {
		?>
		<h1 class="entry-title"><?php _e( 'No Posts Found.', 'travelify' ); ?></h1>
      <?php
   }
}
endif; 

To Child Theme functions.php and you can do whatever you want with it. The same applies for other functions.

Thank you for getting back at me so quickly. This is awesome because it works and I’m a total noob at coding. I did exactly what you said with

travelify_theloop_for_archive
travelify_theloop_for_search
travelify_theloop_for_template_blog_image_large
travelify_theloop_for_template_blog_image_medium

and I changed the_excerpt with the_content for each function and now the whole content of each post is displayed instead of its excerpt and I feel like a boss.

Thanks a lot Aigars :slight_smile:

@pinbeu

No problem. I am glad I could help! :slight_smile:

I tried this method of copying the entire function to my child functions.php for “How to put image below the post title?” and it worked great.

Now, I’m trying to modify the shortcodes.php and tried something similar by copying the code for an entire function into my child functions.php and it didn’t work. It broke my site and said I couldn’t define a function twice.

Do I need to use an if block similar to if ( ! function_exists( 'travelify_theloop_for_template_blog_image_large' ) ) :?

Thanks!

@landing911
If the error is that you are defining the function twice you shold modifiy the parent (original) theme, you should wrap the function:
if ( ! function_exists( ‘travelify_theloop_for_template_blog_image_large’ ) ) :
…original funciton code here
endif;

Now you can define a new function in function.php without having any error. The problem is that you have to remember (write somewhere a note!) that the original theme file is modified, and if in the future you update the theme you will have to apply the same hack.

@Aigars
Why some function are wreapped with function_exists and other not? For example I need to modify the function header-extensions.php and I faced the same problem of Cannot Redeclare Functions, so I have to modify the original theme. If there is not a particular reason for this choice I would suggest to add if ( ! function_exists for this function too.

Thanks, travelify is a great theme and I am working to customize it!

Carlo

hi,
I’m trying to edit the copyright footer in your travelify theme. I’ve followed the sample code found in another thread and put it in the functions.php file in the child travelify theme directory but this does not change the footer text? here is the code that i’m putting in the functions.php file:


<?php

// Replace copyright information from footer-extensions.php

// Remove old copyright text
add_action( 'init' , 'remove_copyright' , 15 );
function remove_copyright() {
        remove_action( 'travelify_footer', 'travelify_footer_info', 30 );
}

// Add new copyright info
add_action( 'travelify_footer' , 'new_footer_info' , 30 );
function new_footer_info() {
   $output = '<div class="copyright">All rights reserved <a href="http://samplewebsite.com" title="BW">Designed By BW</a> Theme by <a href="https://colorlib.com" title="colorlib">colorlib</a></div>';
   echo $output;
}

?>

Am I missing a step, or what am I doing wrong?

@browzy

if you would have made some error it would at least throw some error or take down your website entirely. Are you sure that you have this Child Theme activated?

Hello! How to remove dashed line separating footer and main menu?

I’ve installed the child theme. However, the parent style sheet is taking precedence over the child style. Any suggestions would be greatly appreciated.

Hi,

I have modified the functions.php just what instructed above. I also followed what pinbeu in replacing the_excerpt with the_content to see full display of post but still ineffective. Can you help me on this. Im noob in coding. I really want full display of posts in my site and not excerpts.

Thanks!

I can’t for the life of me figure out how to get templates to show up under page attributes after applying the child theme. Also now under Appearance->Themes it states: ERROR: Template is missing.

Thanks for all your help and hard work.

EDIT:
WOOPS I’m silly, resolved. I had removed

/*
Theme Name: Travelify Child
Theme URI: https://colorlib.com/
Description: Child theme for the Travelify theme
Author: Aigars Silkalns
Author URI: https://colorlib.com/
Template: travelify
Version: 2.0
*/

From style.css of the child theme. Once I added it back all is working now.

Hi There,

This is old thread and to help us keep support thread separates could you please create your own thread for your question here https://colorlibsupport.com/c/travelify-support/ instead of replying on others thread as it makes the thread messy and hard to read.

If you want to you can also add reference of this thread in your newly created thread.

We would be more than happy to help you on your new thread.

Thanks,
Movin

Hello I’m new in this forum. I hope this is the right place for my question.

I have used your nice travelify theme to build a new web site for our sports club and now i have a problem with the header area.
I have putten a picture of a castle into the header area via branding.

The code for this in the child theme is:

@media only screen and (min-width: 1048px) {
	#branding {
		background-image: url(https://tv-frankenstein.de/wp-content/uploads/header_background5.png);
		background-repeat: no-repeat;
		background-position: right;
		background-position: 90% 30%;
	}
}

The slider is
When i activate any submenu a breadcrump is being displayed between the menu and the slider and the castle picture slips a little bit down as you can see at the arrows in the attached pictures . Do you have any idea how i can avoid this slipping of the castle picture.?

Hope you can help me and thank you in advance

@wosch This is old thread and to help us keep support thread separates could you please create your own thread for your question here https://colorlibsupport.com/c/travelify-support/ instead of replying on others thread as it makes the thread messy and hard to read.

If you want to you can also add reference of this thread in your newly created thread.

We would be more than happy to help you on your new thread.

Long time a go that I been here bud thanks to Godaddy I have to start all over again they lost the backup of my site. Now i’m working on local USB server to build my site again bud when i want to activate Travelify and child I got this messages:

Fatal error: Cannot redeclare _verify_isactivate_widget() (previously declared in G:\Backup Laptop\USBWebserver v8.5\USBWebserver v8.5\8.5\root\wp-content\themes\travelify-child\functions.php:14) in G:\Backup Laptop\USBWebserver v8.5\USBWebserver v8.5\8.5\root\wp-content\themes\travelify\functions.php on line 136

Maybe someone cat tell me how to fix it.

Regards

WIMA

@WIMA As requested above please create a separate topic for your question here https://colorlibsupport.com/c/travelify-support/