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

Results from the Forum
ctoweett
tagDiv Member

Yes. Put the code below this code inside the functions.php for the child theme.

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' );}

(I don’t work here).

TheLuckyGuy
Participant
#0

Hello,

I’am new to child themes. But I need to add a code line into the functions.php

How do I add that.

Just install the child theme and put it in or is it not that easy?

Code:
/**
* separate media categories from post categories
* use a custom category called ‘category_media’ for the categories in the media library
*/
add_filter( ‘wpmediacategory_taxonomy’, function(){ return ‘category_media’; } ); //requires PHP 5.3 or newer

Thank’s

havard2k
tagDiv Member

Hi. I’m completely new to WordPress, themes and especially child themes. It is very hard to understand where to begin, but I understand installing a child theme is generally recommended if one need to add code later. But I have more questions than answers. The child theme “tutorial” is not very useful for a beginner, like how do I install one? https://forum.tagdiv.com/the-child-theme-support-tutorial/ I’ve tried uploading it like I did with the “main” newspaper theme (newspaper.zip), but I don’t find a zip file named “childtheme.zip” or similar. I only find a folder named “Newspaper-child” with the files functions.php and styles inside. Do I upload theese files? I have a lot of beginner questions like: Can I still use one of the included demos to start? But I don’t find any help in the documentation. Tips where to start? Don’t want to install one of the demos in the “main” theme and start changing them before I understand how I can safely build the site without risking losing custom settings, content etc.

altpress
Participant
#0

Hi all,

I’m trying to add a Child Theme for Newspaper v8.7.5

This is my structure:

/Newspaper-child
functions.php
style.css

Here’s my functions file:

<?php
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' );
}
);

And my style.css

/*
Theme Name:     Newspaper 8 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
*/

When I try to activate the child theme, everything breaks. What am I doing wrong?

cwamerica
tagDiv Member

I just tried to delete the composer and reinstall it from the version in the recent theme update. I didn’t update anything other than the composer and it crashed my site again with this code:

Fatal error: Uncaught Error: Call to undefined method td_config_helper::get_map_block_shadow_array() in /home/childs18/childsworld.news/wp-content/plugins/td-composer/includes/tdc_map.php:662 Stack trace: #0 /home/childs18/childsworld.news/wp-content/plugins/td-composer/includes/tdc_main.php(32): require_once() #1 /home/childs18/childsworld.news/wp-content/plugins/td-composer/td-composer.php(35): require_once(‘/home/childs18/…’) #2 /home/childs18/childsworld.news/wp-includes/class-wp-hook.php(286): tdc_plugin_init(”) #3 /home/childs18/childsworld.news/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(”, Array) #4 /home/childs18/childsworld.news/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #5 /home/childs18/childsworld.news/wp-content/themes/Newspaper/includes/wp_booster/td_wp_booster_functions.php(207): do_action(‘td_wp_booster_l…’) #6 /home/childs18/childsworld.news/wp-content/themes/Newspaper/functions.php(23): require_once(‘/home/childs18/…’) #7 /home/childs18/childsworld.news/wp-settings.php in /home/childs18/childsworld.news/wp-content/plugins/td-composer/includes/tdc_map.php on line 662

cwamerica
tagDiv Member

[William Wa.] Well here is the error that I was getting when trying to use the WordPress CLI tools:

Fatal error: Uncaught Error: Call to undefined method td_config_helper::get_map_block_shadow_array() in /home/childs18/childsworld.news/wp-content/plugins/td-composer/includes/tdc_map.php:662
Stack trace:
#0 /home/childs18/childsworld.news/wp-content/plugins/td-composer/includes/tdc_main.php(32): require_once()
#1 /home/childs18/childsworld.news/wp-content/plugins/td-composer/td-composer.php(35): require_once(‘/home/childs18/…’)
#2 /home/childs18/childsworld.news/wp-includes/class-wp-hook.php(286): tdc_plugin_init(”)
#3 /home/childs18/childsworld.news/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(”, Array)
#4 /home/childs18/childsworld.news/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#5 /home/childs18/childsworld.news/wp-content/themes/Newspaper/includes/wp_booster/td_wp_booster_functions.php(207): do_action(‘td_wp_booster_l…’)
#6 /home/childs18/childsworld.news/wp-content/themes/Newspaper/functions.php(23): require_once(‘/home/childs18/…’)
#7 /home/childs18/childsworld.news/wp-settings.php in /home/childs18/childsworld.news/wp-content/plugins/td-composer/includes/tdc_map.php on line 662

cwamerica
Participant
#0

I just completed the newest update to the newspaper theme 8.7. Both this update the one previously have crashed my site to the point that I can’t even access the wordpress dashboard. I have had to contact our web host provider to troubleshoot and deactivate enough stuff that I can get in and do a restore.

I have done at least 4 update previously using the Filezilla method and never had a problem.

Is anyone else having this problem? Why are these updates crashing my site, if I can get it back online, I will not we 2 updates behind but I refuse to try updating again if it will just keep crashing my site.

My web host provider has said that it has something to do with one of the Tag plug-ins crashing.

Here is there error I currently see when I try to load my homepage.

Fatal error: Uncaught Error: Call to undefined method td_config_helper::get_map_block_shadow_array() in /home/childs18/childsworld.news/wp-content/plugins/td-composer/includes/tdc_map.php:662 Stack trace: #0 /home/childs18/childsworld.news/wp-content/plugins/td-composer/includes/tdc_main.php(32): require_once() #1 /home/childs18/childsworld.news/wp-content/plugins/td-composer/td-composer.php(35): require_once(‘/home/childs18/…’) #2 /home/childs18/childsworld.news/wp-includes/class-wp-hook.php(286): tdc_plugin_init(”) #3 /home/childs18/childsworld.news/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(”, Array) #4 /home/childs18/childsworld.news/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #5 /home/childs18/childsworld.news/wp-content/themes/Newspaper/includes/wp_booster/td_wp_booster_functions.php(207): do_action(‘td_wp_booster_l…’) #6 /home/childs18/childsworld.news/wp-content/themes/Newspaper/functions.php(23): require_once(‘/home/childs18/…’) #7 /home/childs18/childsworld.news/wp-settings.php in /home/childs18/childsworld.news/wp-content/plugins/td-composer/includes/tdc_map.php on line 662

homesofcolor
tagDiv Member

I am looking for the same functionality as vasik. I found this:

// Add External Link to Featured Image with Custom Field

add_filter('post_thumbnail_html','add_external_link_on_page_post_thumbnail',10);
function add_external_link_on_page_post_thumbnail( $html ) {
if( is_singular() ) {
global $post;
$name = get_post_meta($post->ID, 'ExternalUrl', true);
if( $name ) {
$html = '' . $html . '';
}
}
return $html;
}

and use a custom field on the post page but this isn’t working. I have added this code the my functions.php in my child theme. I assume that maybe there is a script in the theme that is overriding this functionality. Would it be possible to get a small amount of guidance on this. I would very much appreciate it.

What I am trying to do is have the covers to the magazines uploaded as the featured image and have them link to the digital flipbook online. It would be great if this could work.

Twisted Pear
Participant
#0

Hey guys,

I need to extend the td_module_single_mob class but cant work out how to elegantly register my module.

I know the mobile theme doesn’t support child themes (yet), so if I could register my module in the mobile/functions.php file that would be great.

Currently I am adding my module in mobile/includes/td_config_mob.php


td_api_module::add('td_ba_single', array(...));

…but I’d prefer to leave as small a footprint as possible in the parent theme – just adding a few lines to mobile/functions.php. Hopefully that’s doable.

Thanks,

TP

Catalin
tagDiv Staff

Hello lizdi2018,

We have added this suggestion to our list of improvements and we will take into account to the next updates. Another alternative for you would be to make these changes in Child Theme because the header.php and functions.php are overwritten in the child theme, as you can check in our documentation from here -> https://forum.tagdiv.com/the-child-theme-support-tutorial/

Thanks for your understanding!

rmdail
Participant
#0

I have a bunch of customizations that I need to add to the functions.php file, but every time I do it causes a HTTP error 500. I have used many other themes and never had an issue with adding code to the functions.php file.

One of the items I’m trying to add, is listed below:

if (!current_user_can(‘manage_options’)) {
remove_menu_page( ‘jetpack’ );
}
}

add_action(‘jetpack_admin_menu’, ‘hide_jetpack’);

What do I need to do in order to add functions and actions to the functions.php?

rmdail
Participant
#0

Is there a child theme for the latest version of newspaper? I need to make some updates to the functions.php file to add some additional customizations and don’t want to lose the changes when an update is applied.

Tatiane Pires
Participant
#0

I need to insert sharing icons to each of the any number of images a TagDiv Slide Gallery can have.

Digging Newspaper’s files I found td_wp_booster_functions.php and the function td_gallery_shortcode. I tried to override this function from a child theme to add the icons to the variable $slide_display_html, no luck so far.

So how exactly can I get this done from a Newspaper’s child theme?

Note to make things clear:
This question is NOT about the regular post/cpt sharing icons, whose settings are on Theme Panel under Post Settings > Sharing. Before someone makes any weird assumption regarding what I’m asking here.

ivomasterche
Participant
#0

Hello,
Is it possible to edit the gallery slider theme?
I have found the td_gallery_shortcode function but td_wp_booster_functions.php file cannot be changed form my child theme , so is it possible to use a filter hook that will call similar function from my functions.php file instead the one you provide?

Catalin
tagDiv Staff

Hello bellendir,

Notice that change should have to be done in functions.php file which can be changed in our future updates and it will be overwritten. You can try using the child theme according to our documentation from here -> https://forum.tagdiv.com/the-child-theme-support-tutorial/ if you want to make some changes to your core files.

Thanks for your understanding!

Volnus
tagDiv Member

You can add this below code to your child theme functions.php file or a site specific plugin. It should do the trick.

function disable_comment_url($fields) {
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields','disable_comment_url');

mjehangir
Participant
#0

Hi,
I had started a thread but that isn’t helping me. I need some urgent help as my authors are not able to work. Since i have updated to newer theme update of Feb 27, my authors can’t see the list of ‘all posts’ in the admin area. It works normally for ‘admin’ user but all other roles are giving ‘HTTP Error 500’. As you can see the screenshots of morenews.pk

http://prntscr.com/isyfsi
http://prntscr.com/isyfz7

As per your suggestions, i have done a clean install of theme from ftp after removing previous ones. updated the plugins to the latest versions, in fact, reinstalled them from your repository. Removed cache and even disabling other plugins. But it only happens when i start using the latest version of tagDiv Composer on the latest version of theme.

The host tells me the following error in the log file. Can you help me after looking at them as to what thing is causing the issue?

=========
[18-Mar-2018 18:42:43 UTC] PHP Fatal error: require_once(): Failed opening required ‘wp-admin/panel/panel_core/td_panel_data_source.php’ (include_path=’.:/opt/cpanel/ea-php56/root/usr/share/pear’) in /home/morenews/public_html/wp-content/themes/Newspaper/includes/wp_booster/td_wp_booster_functions.php on line 25
[18-Mar-2018 18:42:51 UTC] PHP Fatal error: Class ‘td_global’ not found in /home/morenews/public_html/wp-content/themes/Newspaper-child/header.php on line 24
[18-Mar-2018 18:43:26 UTC] PHP Fatal error: Class ‘td_global’ not found in /home/morenews/public_html/wp-content/themes/Newspaper-child/header.php on line 24
[18-Mar-2018 18:44:35 UTC] PHP Fatal error: Class ‘td_global’ not found in /home/morenews/public_html/wp-content/themes/Newspaper-child/header.php on line 24
[18-Mar-2018 18:44:54 UTC] PHP Fatal error: Class ‘td_global’ not found in /home/morenews/public_html/wp-content/themes/Newspaper-child/header.php on line 24
===============
Thanks.

mjehangir
tagDiv Member

Hi, regarding my above problem, my host sees the following errors in the log file. Can you see what is reason behind the issue after looking at them?
=========
[18-Mar-2018 18:42:43 UTC] PHP Fatal error: require_once(): Failed opening required ‘wp-admin/panel/panel_core/td_panel_data_source.php’ (include_path=’.:/opt/cpanel/ea-php56/root/usr/share/pear’) in /home/morenews/public_html/wp-content/themes/Newspaper/includes/wp_booster/td_wp_booster_functions.php on line 25
[18-Mar-2018 18:42:51 UTC] PHP Fatal error: Class ‘td_global’ not found in /home/morenews/public_html/wp-content/themes/Newspaper-child/header.php on line 24
[18-Mar-2018 18:43:26 UTC] PHP Fatal error: Class ‘td_global’ not found in /home/morenews/public_html/wp-content/themes/Newspaper-child/header.php on line 24
[18-Mar-2018 18:44:35 UTC] PHP Fatal error: Class ‘td_global’ not found in /home/morenews/public_html/wp-content/themes/Newspaper-child/header.php on line 24
[18-Mar-2018 18:44:54 UTC] PHP Fatal error: Class ‘td_global’ not found in /home/morenews/public_html/wp-content/themes/Newspaper-child/header.php on line 24
===============
Thanks.

GadgetViper
tagDiv Member

Also, I’m going through the child theme files included with version 8.7 and I can see style.css has reference to version 7.7 and the functions.php file references V6.3+ I’m guessing these are just old references and not to worry about them?

22p
tagDiv Member

Sorry Bodgan.

I check the documentation but trying to update from “8.2” –> “8.7.1” i do not find any differences in the Child folder downloaded from themeforest.

The files are 3:

functions.php
– screenshot.png
– style.css

These 3 files are the same that i have find in the child folder of 8.2 that download in the past.

Child folder 8.2” and “Child folder 8.7.1” have the same files.

functions.php
– screenshot.png
– style.css

Please can you confirm?
Thanks.

Tatiane Pires
Participant
#0

Hello there! I need some help.

I already checked the page How to use custom post type and taxonomy, and downloaded the suggested plugin td-custom-post-type. It seems to me that this is a “plugin way” to add CPTs other than my “child theme way” to add them.

I’m working with a Newspaper’s child theme, the files cpt-events.php and cpt-photos.php are required from functions.php. Then I rebuild the permalinks from /wp-admin/options-permalink.php whenever I add or remove the require lines.

The issue is that, upon adding these CPTs, TagDiv Composer no longer loads after clicking the button that links to /wp-admin/post.php?post_id=SOME_ID&td_action=tdc

Both CPT files were generated from Generate WP and everything else (other than TagDiv Composer) works flawlessly.

To make things even stranger, after removing cpt-events.php and cpt-photos.php require lines from functions.php, and rebuilding permalinks, TagDiv Composer continues not loading. It will only work if I restore a database backup saved right before activating the CPTs.

I don’t have an URL so that you could login in wp-admin. I’ve been testing it on my local development environment.

I’d like to know if you could take a look in the linked php files. I’m not aware of any CPT setting in those files that could trigger this behavior (composer not loading), perhaps you can spot it.

cantonjester
tagDiv Member

Could I be able to apply the target=“_blank” property limited only to a particular Block type? Or perhaps where I define categories for posts?

At any rate If I’m going to be making changes to the code, I’d need to be able to apply any changes to the child theme’s functions.php anyway to avoid losing any changes made with future theme updates, right?

pem
tagDiv Member

I think my function is not calling at all. I tried below function still it is not displaying anything. I put the below function in functions.php under child theme. I have only “add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’, 1001);” with theme_enqueue_styles function and below function in child theme’s functions.php.

// Shortcode to output a page content in Visual Composer
function page_output_vc_shortcode() {

$test_var = “This is just for testing”;
return $test_var;
}

add_shortcode(‘my_vc_page_output’, ‘page_output_vc_shortcode’);

Do i have to put above function in other file? My shortcode is listed in VC element.

Thank you

Simion C.
tagDiv Staff

You could do that in two ways. Either with a function in functions.php (main or child theme)

function disable_comment_url_email($fields) {
unset($fields['url']);
unset($fields['email']);
return $fields;
}
add_filter('comment_form_default_fields','disable_comment_url_email');

Or hide them with CSS (code entered in Theme panel->Custom CSS)
https://www.screencast.com/t/nKAHr91cdy

.comments .td-form-email,
.comments .td-form-url {
display: none;
}

Thanks

toniacat
tagDiv Member

Hello Simon Thanks for the reply, Yes this blank page is happening when I upload the Child theme, So I have downloaded a new folder with a new child theme zip file and I just now uploaded it and when I activate the theme the live site and the admin site go blank. I called wpengine to see if they could help me and they said its a 500 error and to write your team back that created the theme.

on my staging I also added the child theme and when I went to live site or close the customize section on my admin side I get this message:

Fatal error: Cannot redeclare _check_isactive_widgets() (previously declared in /nas/content/staging/feline13/wp-content/themes/Newspaper-child/functions.php:30) in /nas/content/staging/feline13/wp-content/themes/Newspaper/functions.php on line 208

Would love some help, I too have never had this issue on a child theme, so I don’t know what to do.
T

  • This reply was modified 8 years by toniacat.
Viewing 25 results - 351 through 375 (of 638 total)