Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
Pages: 1
The best way is by creating a child theme.
Then copy the contents.php file from your-theme/template-parts/, modify it, and include it in the child theme folder.
Just playing with the contents.php file on my test site, I changed this section starting on line 52 (or so):
<div class="post-meta">
<p class="post-date">
<time class="date updated" datetime="<?php the_time(__('Y-m-dh:i:s T', 'RB-photo-main-nav-below-masthead')); ?>" pubdate="pubdate"><?php the_time(get_option('date_format')); ?></time>
<?php edit_post_link( __('Edit', 'RB-photo-main-nav-below-masthead'),'',''); ?>
</p>
</div><!-- .post-meta -->
to this:
<div class="post-meta">
<p class="post-date">
Posted by <?php the_author(); ?> on <time class="date updated" datetime="<?php the_time(__('Y-m-dh:i:s T', 'RB-photo-main-nav-below-masthead')); ?>" pubdate="pubdate"><?php the_time(get_option('date_format')); ?></time>
<?php edit_post_link( __('Edit', 'RB-photo-main-nav-below-masthead'),'',''); ?>
</p>
</div><!-- .post-meta -->
But don't just copy and paste what I have here, you'll need your own file that reflects the name of your template.
place your new content.php file in the child theme's folder alongside style.css and functions.php
You can see the result here: http://backlight-rb-test.barbeephoto.co … ing-thing/
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
in case anyone else is following this, I just tried creating a child theme and then simply including my modified content.php file in the child theme directory. Frustratingly, this did not work.
According to the WordPress Codex:
If you want to change more than just the stylesheet, your child theme can override any file in the parent theme: simply include a file of the same name in the child theme directory, and it will override the equivalent file in the parent theme directory when your site loads.
They mean this literally it appears.
Since the content.php file is in the template-parts/ folder of the parent theme, it must also be in a folder of the same name in the child theme's folder. I spent a good hour or two trying to see what I did wrong with code before I took what I thought was a long-shot chance at simply creating a "template-parts" folder and moving the content.php file there. But that's what works.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Exactly.
Plus there are several instances in content.php where the theme name must be changed to the name of the child theme to prevent functions from being void. I will post a writeup with source code to round up this thread as soon as I get on a computer with a keyboard and rename the thread title to something related to child theme creation.
Offline
ooh. good catch.
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Since we're on the topic, here's some template code I've worked up for child themes.
functions.php
<?php
/**
* Load stylesheet from parent, then from child.
*/
function my_theme_enqueue_styles() {
$parent_style = 'parent-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
/**
* Custom script
*/
function enqueue_custom_script() {
if( wp_script_is('jquery','done') ){ ?>
<script>
(function($) {
//$...
})( jQuery );
</script>
<?php }
}
add_action('wp_footer', 'enqueue_custom_script', 22);
?>
style.css
/*
Theme Name: Backlight Child Theme
Theme URI:
Description:
Author:
Author URI:
Template: backlight
Version: 1.0.0
License:
License URI:
Tags:
Text Domain: backlight-child-theme
*/
The functions.php file is the really helpful thing, I guess. ;-)
Offline
This is almost exactly what my files look like.
There is one thing still which I am not completely sure about yet:
When I try to edit a post in a browser while wathing the console, I see a 404 error for the GET on
https://fotos.michilge.de/blog/wp-content/themes/BacklightReseda-child/style_admin.css?ver=4.7
I tried to enqueue that in this way:
wp_enqueue_style( $parent_style,
get_template_directory_uri() . '/style.css',
get_template_directory_uri() . '/style_admin.css'
);
But that didn't do the trick.
For the moment I simply copied the style_admin.css from the Backlight Theme folder to the child theme folder.
But I am quite certain that is not the way it should be done since the file might be changed in the parent theme.
Last edited by michilge (2017-01-08 01:00:24)
Offline
I believe you need a separate wp_enqueue_style() for each stylesheet. Check the Wordpress codex on for details on using the function.
Offline
Hmm.
Themeing the admin pages seems to be something completely different.
According to https://codex.wordpress.org/Creating_Admin_Themes it should by done via a plugin (that makes use of "wp_enque_style()" nevertheless ...)
I looked around a little:
Currently, the file "style_admin.css" is enqueued by the Backlight parent theme via the file "inc/theme_posts.php"
There is a passage
function backlight_post_meta_setup() {
wp_enqueue_style( 'style_admin', get_stylesheet_directory_uri() . '/style_admin.css' );
add_action( 'add_meta_boxes', 'post_meta_post_options' );
I don't really understand why it is searched in the child theme directory then. Shouldn't "get_stylesheet_directory_uri()" from the scope of the parent theme insert the path to the parent theme?
Seems not ...
Or should perhaps "inc/theme_posts.php" use "if ( is_child_theme() )" to test if "get_template_directory_uri()" should be used instead?
I believe, this could perhaps better be changed in the parent theme to make it child-proof.
If I copy "style_admin.css" to the child theme's directory everything is fine of course.
Offline
Shouldn't "get_stylesheet_directory_uri()" from the scope of the parent theme insert the path to the parent theme?
That function returns the directory of the current child theme folder (or theme if no child is being used)
https://codex.wordpress.org/Function_Re … ectory_uri
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline
Pages: 1