Search Results for 'child theme how to functions.php'

    No search results were found in Documentation!

Results from the Forum
Simion C.
tagDiv Staff

Hi,

You can enable the gallery, zoom and slide for product images by adding the code mentioned in this topic
https://github.com/woocommerce/woocommerce/wiki/Enabling-product-gallery-features-(zoom,-swipe,-lightbox)-in-3.0.0
Add the code for the feature you want or all of it, in the theme functions.php file (or child theme functions.php)
https://www.screencast.com/t/B9yGpy73qr

Thanks

AllenForkum
tagDiv Member

My web-hosting support was able to help me resolve the WP login problem, so I again have access to the WP dashboard. They also told me that my site was using a “child” of the Newspaper 4 theme (I don’t know what that means) before the upgrade to Newspaper 8 and that might be why the home page is not loading correctly and why our logo does not appear in headers. Is that an issue for which I may receive support from you guys?

Also, now when I try to activate the Newspaper 8 theme, I get this message:

wp booster error:
Please update your [tagDiv social counter] Plugin!

Fatal error: Call to undefined function mb_detect_encoding() in /home/forkum/public_html/wp-includes/functions.php on line 3086

nasadino
tagDiv Member

Hi,

I read and used that guide to create a child theme, but it didn’t work.
I tried now, I unziped the theme package again and I uploaded the child theme without a modification next to the parent theme on the FTP server but it still the same.
FTP folder: http://www.screencast.com/t/Hv8xUiV8eo0

I have the latest WordPress: http://www.screencast.com/t/Pe5DDGkg
Wordpres Theme settings with the error message: http://www.screencast.com/t/kdT16FGUzv
I have the latest version (8.1) of Newspaper, and the child theme functions.php looks like this: http://www.screencast.com/t/HnrUjrRb9gv

Thank you for your help!

nasadino
Participant
#0

Hello!

I have just bought Newspaper theme [Version 8.1] and I would like to modify some of the modules, but I can’t activate the child theme in WordPress Admin, it says “The parent template is corrupt. Newspaper parent template must be installed.” But the Newspaper v.8.1. parent template is installed. And next to this error message I saw the child theme’s name is “Newspaper 7 Child theme”.

I found another topic where you said I should use “function theme_enqueue_styles()” lines without ‘c’, but it didnt work for me.

My FTP folder look like this:
FTP folder
And here is my child theme functions.php:
Child theme

Thank you!

soundstrat
tagDiv Member

Ok, so I have found the solution…

The functions.php file in the new Newspaper 6.3 is different than the one that was in 6.0

To resolve this issue, go to themes – editor in your dashboard, then replace the following code – making sure NOT to remove any other code. If you remove other code, you may lose custom functionalities that you’ve set in this functions file. Here’s the code:

<?php
/* ----------------------------------------------------------------------------
Newspaper 6 Child theme - Please do not use this child theme with older versions of Newspaper Theme

What can be overwritten via the child theme:
- everything from /parts folder
- all the loops (loop.php loop-single-1.php) etc

- the rest of the theme has to be modified via the theme api:
https://forum.tagdiv.com/the-theme-api/

*/

/* ----------------------------------------------------------------------------
add the parent style + style.css from this folder
*/
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', 1000);
function theme_enqueue_styles() {
wp_enqueue_style('td-theme', get_template_directory_uri() . '/style.css', '', '6.1c', 'all' );
wp_enqueue_style('td-theme-child', get_stylesheet_directory_uri() . '/style.css', array('td-theme'), '6.1c', 'all' );

}

With this:
<?php
/* ----------------------------------------------------------------------------
Newspaper V6.3+ Child theme - Please do not use this child theme with older versions of Newspaper Theme

What can be overwritten via the child theme:
- everything from /parts folder
- all the loops (loop.php loop-single-1.php) etc
- please read the child theme documentation: https://forum.tagdiv.com/the-child-theme-support-tutorial/

- the rest of the theme has to be modified via the theme api:
https://forum.tagdiv.com/the-theme-api/

*/

/* ----------------------------------------------------------------------------
add the parent style + style.css from this folder
*/
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', 1001);
function theme_enqueue_styles() {
wp_enqueue_style('td-theme', get_template_directory_uri() . '/style.css', '', TD_THEME_VERSION, 'all' );
wp_enqueue_style('td-theme-child', get_stylesheet_directory_uri() . '/style.css', array('td-theme'), TD_THEME_VERSION . 'c', 'all' );

}

This worked for me. Please update and let us know if it works for you.

Jens H.
Participant
#0

Hi.

I’ve updated my Newsmag theme to 4.0, but since the update the cronjobs has stopped working. I’ve looked through every logfile and analyzed every module being used.

I know it sounds weird, and I’m not 100% sure that it’s NewsMag 4. But here goes. Has anything changed in functions.php + the child functions.php, that could trigger that behaviour.

I haven’t changed anything else on the site, and I just need someone else than me to either verify or clarify 🙂

In Newsmag 3.x this line
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’, 1000);
In Newsmag 4.x it’s
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’, 1001);

I really don’t know what I’m looking for.

But has other using NewsMag with childtheme had problems with wp-cron not getting scheduled post and scheduled database backups run???

Simion C.
tagDiv Staff

Hi,

You could try entering the filter code for the images in the theme’s functions.php file. Or in the child theme functions file, if a child theme is used.
If you could provide more details about what exactly you are trying to do, maybe we can help you further.

Thanks

mkastrupsen
tagDiv Member

Hi
Thanks for the reply. I’m still unsure on how to call the top menu and set a different menu to it?
I’m using a child theme if that changes anything. I’m calling the code below in functions.php.

I tried this:


function my_wp_nav_menu_args( $args = '' ) {

if( SwpmMemberUtils::is_member_logged_in() ) { 
	$args['tds_top_menu'] = 'Top-Bar-Menu-Logged-In';
	
	echo "Logged in";
} else { 
	$args['tds_top_menu'] = 'Top-Bar-Menu-Logged-Out';
	echo "Logged out";
} 
	return $args;
}
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
22p
tagDiv Member

More details:

– We have “master theme 8.0” and “child theme 7.7c”
Functions.php is empty
– We use Woocommerce 3.10, WooCommerce Subscriptions, WooCommerce Membership (and here there is no log problem).

bz
Participant
#0

Hello,

We have a small WooCommerce-based store on our website that uses your wonderful Newspaper theme. Due to the fact that PayPal does not natively support our local currency, a few snippets have been added to the child-theme’s functions.php file to add currency conversion to EUR. All this works perfectly on desktops.

However, when the website is loaded on a phone or through Chrome’s Responsive Web Design Tester extension, the option to pay with PayPal no longer appears on the checkout page.

Is it possible that these particular snippets mentioned above are for some reason not loaded on the mobile version? If so, what could we do to make them be used?

Thank you!

danielalonso
Participant
#0

Two questions in one about Newspaper 8

Why the Theme custom CSS is so slow?
I mean, if I alter the padding, the font size or other elements, they only take effect after the page is loaded, what is frustrating as the reader “sees” the changes.

Child style.css issues seems not to be working
To avoid it, I’m writting the changes in the child theme style.css. But the changes don’t take effect, nothing happens.

Although my php files in the child theme work fine (header.php, functions.php and so on), style.css seems not to be working.

My child style.css:
/*
Theme Name: Newspaper 7 Child theme
Theme URI: http://themeforest.net/user/tagDiv/portfolio
Description: Child theme made by tagDiv
Author: tagDiv
Author URI: http://themeforest.net/user/tagDiv/portfolio
Template: Newspaper
Version: 7.7c
*/

/* —————————————————————————-
This file will load automatically when the child theme is active. You can use it
for custom CSS.
*/

/* Increases the font size */

@media
(max-width: 767px) {
.td-page-content p, .td-post-content p, .wpb_text_column p, .td_block_text_with_title p, .woocommerce #tab-description p, .mce-content-body p, .td-page-content li, .td-post-content li, .wpb_text_column li, .td_block_text_with_title li, .woocommerce #tab-description li, .mce-content-body li {
font-size: 125%;
line-height: 26px;
}
}

/* Modify the header background color */
.td-banner-wrap-full {
background-color: #ab1b1b;
}

Could you replicate this issue?

Thanks,
Daniel

VoZz
tagDiv Member

Hi Simion,

Thank you for your response.

I checked the first issue and it’s only happends on Firefox. Chrome seems to work fine.

The background issue is fixed by activating the parent theme. I only have a functions.php, page.php and header.php besides the style.css in my child theme. I figured out it’s the page.php that is causing the problem.

I don’t just want to throw it out, because it’s in there for a reason, but it has been a while since I’ve edited it. I have no clue what I changed, can you recognize anything?

<?php
/* ----------------------------------------------------------------------------
the default page template
*/

get_header();

//set the template id, used to get the template specific settings
$template_id = 'page';

$loop_sidebar_position = td_util::get_option('tds_' . $template_id . '_sidebar_pos'); //sidebar right is default (empty)

//get theme panel variable for page comments side wide
$td_enable_or_disable_page_comments = td_util::get_option('tds_disable_comments_pages');

//read the custom single post settings - this setting overids all of them
$td_page = get_post_meta($post->ID, 'td_page', true);
if (!empty($td_page['td_sidebar_position'])) {
$loop_sidebar_position = $td_page['td_sidebar_position'];
}

// sidebar position used to align the breadcrumb on sidebar left + sidebar first on mobile issue
$td_sidebar_position = '';
if($loop_sidebar_position == 'sidebar_left') {
$td_sidebar_position = 'td-sidebar-left';
}

/**
* detect the page builder
*/
$td_use_page_builder = td_util::is_pagebuilder_content($post);

if ($td_use_page_builder) {

// the page is rendered using the page builder template (no sidebars)
if (have_posts()) { ?>
<?php while ( have_posts() ) : the_post(); ?>

<div class="td-main-content-wrap td-main-page-wrap">
<div class="td-container">
<?php the_content(); ?>
</div>
<?php
if($td_enable_or_disable_page_comments == 'show_comments') {
?>
<div class="td-container">
<div class="td-pb-row">
<div class="td-pb-span12">
<?php comments_template('', true); ?>
</div>
</div>
</div>
<?php
}
?>
</div> <!-- /.td-main-content-wrap -->

<?php endwhile; ?>
<?php }
} else {

//no page builder detected, we load a default page template with sidebar / no sidebar
?>

<div class="td-main-content-wrap">
<div class="td-container <?php echo $td_sidebar_position; ?>">
<div class="td-crumb-container">
<?php echo td_page_generator::get_page_breadcrumbs(get_the_title()); ?>
</div>
<div class="td-pb-row">
<?php
switch ($loop_sidebar_position) {
default:
?>
<div class="td-pb-span8 td-main-content" role="main">
<div class="td-ss-main-content">
<?php
if (have_posts()) {
while ( have_posts() ) : the_post();
?>
<div class="td-page-header">
<h1 class="entry-title td-page-title">
<span><?php the_title() ?></span>
</h1>
</div>
<div class="td-page-content">
<?php
the_content();
endwhile;//end loop

}
?>
</div>
<?php
if($td_enable_or_disable_page_comments == 'show_comments') {
comments_template('', true);
}?>
</div>
</div>
<div class="td-pb-span4 td-main-sidebar" role="complementary">
<div class="td-ss-main-sidebar">
<?php get_sidebar(); ?>
</div>
</div>
<?php
break;

case 'sidebar_left':
?>
<div class="td-pb-span8 td-main-content <?php echo $td_sidebar_position; ?>-content" role="main">
<div class="td-ss-main-content">
<?php

if (have_posts()) {
while ( have_posts() ) : the_post();
?>
<div class="td-page-header">
<h1 class="entry-title td-page-title">
<span><?php the_title() ?></span>
</h1>
</div>
<div class="td-page-content">
<?php
the_content();
endwhile; //end loop
}
?>
</div>
<?php
if($td_enable_or_disable_page_comments == 'show_comments') {
comments_template('', true);
}?>
</div>
</div>
<div class="td-pb-span4 td-main-sidebar" role="complementary">
<div class="td-ss-main-sidebar">
<?php get_sidebar(); ?>
</div>
</div>
<?php
break;

case 'no_sidebar':
?>
<div class="td-pb-span12 td-main-content" role="main">

<?php
if (have_posts()) {
while ( have_posts() ) : the_post();
?>
<div class="td-page-header">
<h1 class="entry-title td-page-title">
<span><?php the_title() ?></span>
</h1>
</div>
<div class="td-page-content">
<?php
the_content();
endwhile; //end loop
}
?>
</div>
<?php
if($td_enable_or_disable_page_comments == 'show_comments') {
comments_template('', true);
}?>
</div>
<?php
break;
}
?>
</div> <!-- /.td-pb-row -->
</div> <!-- /.td-container -->
</div> <!-- /.td-main-content-wrap -->

<?php
}

get_footer();

dancort
Participant
#0

Hey guys. I posted this on Stackoverflow:

http://stackoverflow.com/questions/44082162/child-theme-wordpress-override-custom-options-on-functions-php-according-to-url

Could you help me out on this one please?

WillRobins
tagDiv Member

Hi Catalin,

Thanks for the advice. We’ve made a lot of progress.

1. We’ve updated the theme and are now using version 7.8.1
2. We’ve deactivated WP Supercache while we’re working on the site
3. We created a child theme. Here’s how it looks:

Newspaper-child
….parts
……..header
…………logo-mobile.php
….functions.php
….screenshot.png
….style.css

Contents of style.css:
/*
Theme Name: Newspaper 7 Child theme
Theme URI: http://themeforest.net/user/tagDiv/portfolio
Description: Child theme made by tagDiv
Author: tagDiv
Author URI: http://themeforest.net/user/tagDiv/portfolio
Template: Newspaper
Version: 7.7c
Text Domain: Newspaper-child
*/

/* —————————————————————————-
This file will load automatically when the child theme is active. You can use it
for custom CSS.
*/

Contents of functions.php:

<?php
/* —————————————————————————-
Newspaper V6.3+ Child theme – Please do not use this child theme with older versions of Newspaper Theme

What can be overwritten via the child theme:
– everything from /parts folder
– all the loops (loop.php loop-single-1.php) etc
– please read the child theme documentation: https://forum.tagdiv.com/the-child-theme-support-tutorial/

– the rest of the theme has to be modified via the theme api:
https://forum.tagdiv.com/the-theme-api/

*/

/* —————————————————————————-
add the parent style + style.css from this folder
*/
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’, 1001);
function theme_enqueue_styles() {
wp_enqueue_style(‘td-theme’, get_template_directory_uri() . ‘/style.css’, ”, TD_THEME_VERSION, ‘all’ );
wp_enqueue_style(‘td-theme-child’, get_stylesheet_directory_uri() . ‘/style.css’, array(‘td-theme’), TD_THEME_VERSION . ‘c’, ‘all’ );

}

When I make changes to parts -> header -> mobile-logo.php those changes are not reflected on the site when I view them from a mobile device.

As an experiment I removed a semicolon from the end of a line in mobile-logo.php to generate a syntax error. Nothing happened on the site.

Digging deeper I went to the parent theme and deleted a semi-colon from the same file to see if it was being picked up there. No dice! After that I went crazy and created several syntax errors in different files to see if I could crash the site. None of my changes had any effect. After that I put everything back.

Is there caching going on somewhere else besides my plugin? What else could be going on to explain that none of my changes at the filesystem level are taking effect?

WillRobins
tagDiv Member

Hi Catalin,

Thanks for the advice. We’ve made a lot of progress.

1. We’ve updated the theme and are now using version 7.8.1
2. We’ve deactivated WP Supercache while we’re working on the site
3. We created a child theme. Here’s how it looks:

Newspaper-child
….parts
……..header
…………logo-mobile.php
….functions.php
….screenshot.png
….style.css

Contents of style.css:
/*
Theme Name: Newspaper 7 Child theme
Theme URI: http://themeforest.net/user/tagDiv/portfolio
Description: Child theme made by tagDiv
Author: tagDiv
Author URI: http://themeforest.net/user/tagDiv/portfolio
Template: Newspaper
Version: 7.7c
Text Domain: Newspaper-child
*/

/* —————————————————————————-
This file will load automatically when the child theme is active. You can use it
for custom CSS.
*/

Contents of functions.php:

<?php
/* —————————————————————————-
Newspaper V6.3+ Child theme – Please do not use this child theme with older versions of Newspaper Theme

What can be overwritten via the child theme:
– everything from /parts folder
– all the loops (loop.php loop-single-1.php) etc
– please read the child theme documentation: https://forum.tagdiv.com/the-child-theme-support-tutorial/

– the rest of the theme has to be modified via the theme api:
https://forum.tagdiv.com/the-theme-api/

*/

/* —————————————————————————-
add the parent style + style.css from this folder
*/
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’, 1001);
function theme_enqueue_styles() {
wp_enqueue_style(‘td-theme’, get_template_directory_uri() . ‘/style.css’, ”, TD_THEME_VERSION, ‘all’ );
wp_enqueue_style(‘td-theme-child’, get_stylesheet_directory_uri() . ‘/style.css’, array(‘td-theme’), TD_THEME_VERSION . ‘c’, ‘all’ );

}

When I make changes to parts -> header -> mobile-logo.php those changes are not reflected on the site when I view them from a mobile device.

As an experiment I removed a semicolon from the end of a line in mobile-logo.php to generate a syntax error. Nothing happened on the site.

Digging deeper I went to the parent theme and deleted a semi-colon from the same file to see if it was being picked up there. No dice! After that I went crazy and created several syntax errors in different files to see if I could crash the site. None of my changes had any effect. After that I put everything back.

Is there caching going on somewhere else besides my plugin? What else could be going on to explain that none of my changes at the filesystem level are taking effect?

22p
tagDiv Member

Sorry the question was:
What “functions.phpchild theme release to use? V6.3+?

devpaq
Participant
#0

I am trying to set that when there is no featured image, it should look for the first image in the article and post that. I tried a few approaches, but none seemed to work.
Am I able to use post_thumbnail_html with this theme?

For example, I tried this in functions.php


function auto_featured_image() {
global $post;

if (!has_post_thumbnail($post->ID)) {
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );

if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
$img = 'ID) . '" />';
apply_filters('post_thumbnail_html', $img, $post->ID, $attachment_id);

}
}
}
}
add_action('the_post', 'auto_featured_image');

alpaca
tagDiv Member

Thank you Simion,

it took me only a small change in the child theme!

1. added register_nav_menus in functions.php
2. changed ‘theme_location’ from ‘header-menu’ to ‘header-menu-mobile’ in /parts/menu-mobile.php

This is really one of the best themes,
Thank you!

kobealbo
tagDiv Member

Okay, totally my fault for not looking into the way the child theme worked for this theme. The Functions file that enqueues the CSS files is a little different than. Copied the functions.php code from the file in the folder provided by the author, and all is good

Mircea Burdusa
tagDiv Member

Thank you for your response.

I have a few follow-up questions:

1) Do you plan to make this section pluggable from child theme in future versions? Maybe wrapping each API call in a function and wrapping the function in a condition like if {!function_exists(function))} will allow users to override the thumbnails settings from functions.php.

2) If I make custom thumbnail sizes using the API, how will I be able to use those new thumbnails in the block templates? I see the thumbnails are called in includes/modules/td_module_#.php files. How can I modify these files so that the new template is preserved after theme update? If I make a copy of the file in the child theme using the same folder structure, will my file get precedence before the theme file in generating the output?

And on an unrelated topic, will you consider making available two licenses with each theme purchase, one for the live site and one for the development site? The guys at Themco do this for their X theme and you register your live and development site on their platform and you are able to make automatic theme updates on the development site. Right now I have the theme installed on my development site but I have the „Acticvate theme” error message on my dashboard. Once I move the site to the live domain I will activate the license I bought, but would be interesting to have a development license as well.

Best regards,
Mircea

Mircea Burdusa
Participant
#0

Hello,

I searched the forum but I didn’t found an answer to my question. All I found was this topic: https://forum.tagdiv.com/topic/how-to-change-the-thumps-on-module-block-sizes/ where a user modified the front width of elements and because of this the thumbnails are not shown properly.

I want to do the same thing. I have modified the width of the main container on the frontend and I want to edit the dimensions of the thumbnails generated by the theme for various blocks. I have found the place in the theme where this sizes are set, in Newspaper-tf\includes\td_config.php line 1324-1593. But I do not want to edit the theme files, because all of my edits will be gone on the next theme updates.

I am looking for a way to hook into those functions and change the size of the generated thumbnails for various blocks from the functions.php file of the child theme, so that my edits will be there after the next theme update.

Best regards,
Mircea

Simion C.
tagDiv Staff

Hi,

You will have to enter the code in the child theme functions.php file, if you have the child theme activated
https://www.screencast.com/t/ezIoeMuwKq
The child theme is provided in the theme package, more information here – https://forum.tagdiv.com/the-child-theme-support-tutorial/

Thanks

msimktg
Participant
#0

I added custom taxonomy (Wrote code in newspaper child theme functions.php)
Now I want to add taxonomy filter in Block Filter Settings (Visual Composer element created by newspaper theme).
Can you please guide me how can I add taxonomy filter for all Blocks?
https://drive.google.com/file/d/0B9HAxPYelymTXzZ2MW56cnRON3M/view?usp=sharing

Thank you in advance

triowebdev
tagDiv Member

Problem appears to be solved by changing this line in the theme:
/includes/wp_booster/td_wp_booster_functions.php
LINE 2115

$content_width is set to 640. Changing this to any other value or commenting out this line solves the problem. Not sure how this global variable is used by the theme.

Added this to the child theme functions.php file to solve the problem.


if (!isset($content_width)) {
$content_width = 650;
}

simchris
tagDiv Member

Theme doesn’t manage SSL or Facebook counts, technically.

So, when you change your URL, it’s no longer the same URL, as treated by FB. There are some hacks out there, which generally need to be done in the main functions.php file.

Also, you need to ensure
a) you have set the https url explicitly in your wp-config.php file
b) done a search/replace for http/your site to https/your site in yout MySQL dbase
c) setup a redirect in your htacess file for all http requests to > https

Whatever hack you use aside from the above “required” stuff for moving to https, be aware it may not always work as you are tricking FB into seeing the old link as the new link, when technically it’s not the same URL.

Much like adding the new site to your Google search console, they stupidly consider it a new site, and does not replace the original in your search console; also note inbound links will show different, and your indexing may change for up to 3 months with the shift.

It’s very much worth doing and should be considered required to be https these days, but you have run into just one of the many issues in the ‘move.’

Try putting the function into the *main* theme functions file. This is one of the many reasons I never use child themes; makes this kind of thing notably trickier as the child theme is essentially a CSS redirect to over-ride the main theme.

Viewing 25 results - 401 through 425 (of 638 total)