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

    No search results were found in Documentation!

Results from the Forum
Anamaria
tagDiv Staff

Hello,

Please check this topic https://forum.tagdiv.com/topic/co-authors-2/ ->https://forum.tagdiv.com/adding-multiple-authors-articles/

Also, this method works for the default post templates and does not affect cloud library templates.
Adding the multiple authors is a 3 step process. Adding the multiple authors is a 3 step process.
Step 1 – Adding the required functions in your child theme functions.php file.
We created 2 custom functions for the author and for the author box which we can then call on the post styles and not have to use the entire functions each time.
Add these functions in your child theme functions.php file: https://pastebin.com/ciYrSZvQ
These will create the custom implementation to add the co-author and the author box for each co-author in particular.
Step 2 – Adding the single post templates to your child theme.
In your main child theme folder, you will need to create the following folder structure: In your main child theme folder, you will need to create the following folder structure:
Newspaper-child/parts/single Newspaper-child/parts/single
Then, under the “single” folder add both the single-template and the loop-single files for each of the post styles you use on your articles => https://i.imgur.com/PNke9Eo.png
Now you will have to identify where the author is being called in each post style.
For styles 1, 5, 9 and 10 you will find the author code in the loop-single files while for styles 2, 3, 4, 6, 7, 8, 11, 12 and 13 the code is found under the single_template files.
Edit the files corresponding to the style you want to apply the co-authors to and then call the functions added at step 1. Replace the default author and author box codes:
https://i.imgur.com/AvJOQfg.png
Replace the highlighted code with the following codes: https://pastebin.com/fifu70QS

Maintain the position of the code in the PHP file though for proper results.

Step 3 – CSS styling.

For the co-authors to position properly we also need a bit of CSS code to ensure proper styling so please add the following CSS code in the theme panel under custom code-> custom CSS:
https://pastebin.com/dRaStewQ

Now you simply need to edit your post and add multiple authors using the plugin author field:https://i.imgur.com/4saivlH.png

Thank you!

Beanzy
tagDiv Member

Hi,

I’m trying to add a paragraph of text at the bottom of every article.

The “prebuilt websites” section says “current demo installed: video news”. I’m not currently using a cloud template – that says “no template”. The “default site post template” is “style 11”.

For reference, prior to upgrading from theme version 9 to theme version 11, I was able to add the paragraph of text in the child theme using loop-single-11.php.

I am trying to edit the loop-single.php file now that I’ve got theme version 11. However, it doesn’t seem to take effect. I turned off the child theme, and edited the file directly in the parent theme and it doesn’t seem to take effect. (However, I can edit header.php and functions.php and see a change, so I assume it’s not something odd like server cache).

I appreciate your help.

marcorroma
Participant
#0

Hello,
currently on my site all the .js files are combined and minified, with the exception of the .js jquery and the .js of the plugin that manages the lazy loading of the images.
I have already disabled this setting of your theme: theme panel – template settings – image loading – use loading animation image = off.
I also disabled WordPress core lazy loading, via the php function in the theme child’s functions.php file.

My problem is that the images don’t start loading unless the whole .js file is loaded first with all the .js combined. Why? Is there a lazy load image option in your theme to disable?

If there is a .js file of your theme that manages the images (which would not load, if this .js is not loaded) I could exclude it to make the loading of the first images faster.

Thanks for support.

Amit
tagDiv Member

@sandyseoane

After updating the Newspaper theme, install and activate tagDiv Standard Pack and tagDiv Composer. This will keep your old design working.

Optional: Then you can start building/redesigning your website templates using tagDiv Cloud Library. Once you’re done with all required templates creation. You can enable them from the theme panel and choose to deactivate tagDiv Standard Pack plugin and optimize your website for better speed and performance.

P.S. If you are using a child theme, you need to update it as well. (especially functions.php file)

I hope you will find this helpful.

AEGISAlliance
tagDiv Member

Hi, I know this is an old thread, but I had run into the same problem. I just figured out that I can simply disable lazy load for all images of a specific size instead of for classes like the mobile version problem.

I changed the image sizes that the mobile version plugin uses by editing the mobile theme files such as single.php. There was an issue with the mobile theme using big images by default that slows down a website. The only problem is that I had to add code into the mobile functions.php, and I have to keep the scripts backed up because it’ll all disappear after the plugin updates. Really wish TagDiv would give us a child theme for the mobile plugin.

So, I simply added this into WP Rocket lazy load exclusion settings and now lazy load is disabled for all images of this size:

-533×261.jpg
-533×261.webp

It isn’t the best method, but it’ll have to do.

Calin
tagDiv Staff

Hi rinkdemi, I think that this font is the default one from browser and this is usually, display until the one set in the theme it is load.
Some tips will be to preload the fonts, this can be done using some cache/optimize plugins, or adding the code in functions.php (it is indicate to use child theme for this) -> https://www.infophilic.com/get-almost-100-pagespeed-newspaper-theme/#preload-newspaper-theme-fonts.
Also another method that it has good results it is to use a custom font, set it as general and disable the rest of the fronts, like google fonts … -> https://i.imgur.com/78NY2Yn.png -> https://i.imgur.com/YfPMFNk.png -> https://i.imgur.com/1KFt8YN.png
I hope this will help you!
Let me know the results!

gbmagazine
Participant
#0

Error message: Warning: Use of undefined constant ‘after_setup_theme’ – assumed ‘‘after_setup_theme’’ (this will throw an Error in a future version of PHP) in /home/customer/www/greenbeltmagazine.com/public_html/wp-content/themes/Newspaper-child/functions.php on line 32

Warning: Use of undefined constant ‘wc_extra’ – assumed ‘‘wc_extra’’ (this will throw an Error in a future version of PHP) in /home/customer/www/greenbeltmagazine.com/public_html/wp-content/themes/Newspaper-child/functions.php on line 32

see screenshot: https://tinyurl.com/yh7mekzw

Live Website: http://www.greenbeltmagazine

This error has been there since many days and we are not able to figure out how to fix this. Please let us know the solution ASAP!

Thanks a lot

Calin
tagDiv Staff

Hi,
If you want to use the custom fields, then you need to add the code in functions.php in this file path wp-content/plugins/td-composer/legacy/Newspaper/functions.php or better set it in child theme, after that go in a post and add the new custom filed -> https://i.imgur.com/PV6YhJY.png set the guest-author and set the value for it -> https://i.imgur.com/kAXOu2B.png the results will be -> https://i.imgur.com/wzujZ0j.png
I hope this will help you!

almostrealthings
tagDiv Member

Hi, I have tried again exactly as you did and cleared the cache and it still does not work, as seen here:
https://almostrealthings.com/product/cultivate-showcase-ticket/
I do not have a child theme in use so the code is in wp-content/plugins/td-composer/legacy/Newspaper/functions.php

Does it matter that I’m still on version 10.3.7?

Thank you,
Zach

Anamaria
tagDiv Staff

Hello,

After the latest theme updates that code needs to be set on this path => wp-content/plugins/td-composer/legacy/Newspaper/functions.php or you can use simply a child theme a set the code in the function.php file from the child theme.

Thank you!

Sigi
tagDiv Member

Thnx for the response.

Yes and that’s not how I would like to show my blog. In settings I’ve made it look like M16 (like it shows at the categories: tinyurl.com/4acnnbpj )

I’ve installed the child theme with the sample child theme. So only style.css and functions.php are in the map. In the functions the only thing I added is:

}

add_action( 'init', function() {
$GLOBALS['wp_rewrite']->pagination_base = 'pagina';
});

So I don’t understand why I can’t change the way it looks on the frontpage…

slivertorp
Participant
#0

Hi there, I wanted to ask you, is your child theme documentation up to date?
https://forum.tagdiv.com/the-child-theme-support-tutorial/

It says:
“!Important:
Since all of the theme functionality was moved to the tagDiv Standard Pack, the root theme folder is wp-content\plugins\td-standard-pack\Newspaper. ”

But inside: wp-content/plugins/ I don’t have any folder called: td-standard-pack
Screenshot: https://imgur.com/nc6YH1T

Would you be able to point me to the right direction in order to modify safely the functions.php file?
Do I still need to create a child theme? Is there any solution for that within the current theme?

Thank you very much.
Adrien

slivertorp
Participant
#0

Hi there!
I really like your theme and I enjoy creating my website with it, so thank you for that.

I have a simple question for you: where is the safest place to add php functions into the theme?
There are some php functions that I need to grab from there: https://wpgridbuilder.com/add-ons/map-facet/ the developer told me to modify functions.php from the child theme but I wanted to ask you first if there is a better way with Newspaper.

I would like this script to not be deleted every time I update the theme.

Thanks in advance for your help.
Adrien

Mystic
Participant
#0

HI there,

We are using the newspaper theme (Version: 10.4) with tagdiv mobile, composer, standard pack and official AMP plugins.
We are using mobile + AMP theme in Transitional mode
We would like to customize the template for posts, currently the AMP pages uses the template /wp-content/plugins/td-composer/mobile/single.php
Based on documentation of AMP plugin I added the newspaper-child theme and created a folder called amp in the child theme root and copied the single.php file to this folder renamed it to blog.php and created another copy and renamed to home.php, then added the following filter in the child theme functions.php:
add_filter( 'amp_post_template_file', function ( $template, $template_type, $post ) {
if ( 'page' === $template_type && 'page' === get_option( 'show_on_front' ) ) {
if ( (int) get_option( 'page_on_front' ) === $post->ID ) {
$template = dirname( __FILE__ ) . '/amp/home.php';
} elseif ( (int) get_option( 'page_for_posts' ) === $post->ID ) {
$template = dirname( __FILE__ ) . '/amp/blog.php';
}
}
return $template;
}, 10, 3 );

However the amp pages still called the posts template single.php from the td-composer plugin!!
I also tried adding the following filter in child theme functions.php:
add_filter( 'amp_post_template_file', function ( $file, $type ) {
if ( 'single' === $type ) {
$file = dirname( __FILE__ ) . '/amp/blog.php';
}
return $file;
}, 10, 3 );

This also doesn’t work.

Please let me know how do I create a custom template for posts only AMP pages without modifying the single.php in the td-composer plugin because when the plugin is updated, my customization will be lost.

Thanks!

mrant
tagDiv Member

Thank you for the quick response.

For others who may be here looking in the future, what I have done to work around this is to create a shortcode that produces the required PHP output and then popped that shortcode into a page using the Column Text Element.


add_shortcode('myshortcode', 'my_shortcode');

function my_shortcode($atts) {
extract(shortcode_atts(array(
'name' => FALSE
), $atts));

$name = esc_html($atts['name']);

$output = 'Hello '.$name;

return $output;
}

Then within the child theme functions.php file I have added


function my_add_rewrite_rules( $rules ) {
$new_rules = array();
$new_rules['^something/(.*)/?'] = 'index.php?pagename=dynamicpage&x=$matches[1]';
return $new_rules + $rules;

}
add_action('rewrite_rules_array', 'my_add_rewrite_rules');

All pages in the form https://mysite.com/something/xxxx gets rewritten to the page and then the shortcode can pull the x query variable to produce the correct output.

Hope this helps someone.

Ant

Anamaria
tagDiv Staff

Hi,

we have sent this information to our developers and following the investigations, this notification does not come from our theme.
Also, according to this topic from WP support
https://wordpress.org/support/topic/sharedarraybuffers/ to fix the problem you need to set that code in functions.php wp-content/plugins/td-composer/legacy/Newspaper/functions.php or if you use the child theme you can set it in the functions.php from there.

Thank you!

Anamaria
tagDiv Staff

Hello,

Single Post Template from Cloud Library can be edited on front-end with tagDiv Composer, this is the only way and will it work. tagDiv Cloud Library is a special custom post type made for our theme and all cloud templates that are built with it are store in the database. Therefore will not work if copy the shortcode and disable the plugin.
If you want to make a template with code you can edit a standard template from the tagDiv standard pack and you can set it in the child theme.

The mobile theme comes with its own templates for page, post, category, etc so your current templates from the desktop theme will get converted to the mobile theme layout, the page content is made without builders in mobile editor => https://www.screencast.com/t/xbgZG8kH also, the options that are provided to edit the mobile theme version are limited (this keeps the things simple).
Also, with our theme, you can use for mobile the responsive version of the theme, the mobile theme plugin or the mobile page editor (this can be edit with tagDiv Composer).
You can check this video about the Newspaper theme version on mobile -> https://www.youtube.com/watch?v=SpGkOnJeNZY

About the custom header, please notice that we can provide support only for theme functions and for custom implementation. For this, you need to contact the custom services -> https://tagdiv.com/premium-customization-services/

Also, for implantation and compatibility for untested and custom plugins, you need to contact work ->https://tagdiv.com/premium-customization-services/

Also, make sure the code you set in the functions.php is set in child theme functions.php or this path => wp-content/plugins/td-composer/legacy/Newspaper/functions.php

Thank you!

fierorelax
Participant
#0

Hi, i’ve deactivated the “SHOW SIGN IN / JOIN” option in my theme panel, removed all “Header login” elements from my cloud templates with TD Composer, but the modal code still shows up in my frontend and i can still use it to login, register and request a new password.

This modal is really unsafe as it has no captcha nor any other check.
In 2021 it is optimistic at the very least.
How can i prevent the modal’s code from showing up in my source code and in comments?

I can’t find any template to overwrite in my child theme to remove it .
If anyone’s interested, i’ve at least disabled the unsafe ajax calls, adding this code to my child theme’s functions.php :

add_action('wp_ajax_nopriv_td_mod_login','my_theme_disable_ajax', 0);
add_action('wp_ajax_td_mod_login', 'my_theme_disable_ajax', 0);
add_action('wp_ajax_nopriv_td_mod_register', 'my_theme_disable_ajax', 0);
add_action('wp_ajax_td_mod_register', 'my_theme_disable_ajax', 0);
add_action('wp_ajax_nopriv_td_mod_remember_pass', 'my_theme_disable_ajax', 0);
add_action('wp_ajax_td_mod_remember_pass', 'my_theme_disable_ajax', 0);
function my_theme_disable_ajax(){
die(json_encode(array('login', 0, __td('Ooops... Error 404', TD_THEME_NAME))));
}

Thanks

luke-tt
Participant
#0

Hi,

I tested the ‘Start SEO data optimization’ on Yoast SEO and it failed. The support said it was something at my side.

My Hoster said:

The error reports that ‘js_search_filter’ function wasn’t found. I see it was called by the Theme in this file: wp-content/themes/Newsmag-child/functions.php
There were no other errors or warning in PHP or Apache log during the process.

and gave me this info:

{…}
​component: "Plugin: wordpress-seo-premium"
​file: "wp-includes/class-wp-hook.php"
​key: "72ad45a5e822047537248a8e135cb3a8"
​line: 292
​message: "call_user_func_array() expects parameter 1 to be a valid callback, function 'js_search_filter' not found or invalid function name"
​stack: Array(4) [ "do_action_ref_array('pre_get_posts')", "WP_Query->get_posts()", "Yoast\\W\\S\\I\\A\\Admin_Columns_Cache_Integration->fill_cache()", … ]
​type: "warning"
​<prototype>: Object { … }

What can I do to call the js_search_filter in the functions.php?

Thank you in advance and best regards,
Luke

Breinblik
Participant
#0

Hi!
I need to have different post types and i’m not sure if it would be sufficient to just place regular posts under a different category. If i would decide to use custom post types what would be the best solution and most compatible with your theme? Do i need to make changes in a functions.php in the child theme or perhaps a plugin?

Thanks for your help!
– Jacco

PFC
tagDiv Member

Hello Calin,

Sorry for the delayed response.

Well, writing over the parent style-buddypress.css file didn’t work, so I tracked down the enqueued name for it. style-buddypress.css is enqueued as ‘td-theme-buddypress’.

So it’s very easy to take it over, buy dequeuing it then renenquing it in child functions.php file.

function renenquing_buddypress_styles() {
wp_dequeue_style( 'td-theme-buddypress' );
wp_enqueue_style('td-theme-buddypress', get_stylesheet_uri() . '/style-buddypress.css');
}
add_action('wp_enqueue_scripts', 'renenquing_buddypress_styles');

Thank you for your assistance.

PFC
tagDiv Member

Hello Calin,

I needed to make adjustments to the css for BuddyPress related page elements. All of them. For example, changing the background colour of the buttons that are hoovered over. A simple example:

#buddypress a.button:hover span,
a.bp-title-button:hover span,
#buddypress ul.button-nav li a:hover span,
#buddypress a.button:focus span,
a.bp-title-button:focus span,
#buddypress ul.button-nav li a:focus span,
#buddypress a.button:active span,
a.bp-title-button:active span,
#buddypress ul.button-nav li a:active span {
background-color: #a11ff2;
}

I have way more edits and changes that are needed. I could target this directly from the child theme css file. But this isn’t the correct way to do this according to BuddyPress documentation.

BuddyPress requests that a separate companion CSS file be offered, style-buddypress.css is the file Newspaper is using. However, it’s not being enqueued via functions.php, so it must be somewhere else in the theme’s additional plugin that it’s being setup. Having an edited version in the child-theme doesn’t work.

If the mechanism behind enqueuing this style-buddypress.css file can be understood, it’s probably easier to de-enqueue and re-enqueue for the child theme file instead.

For me, this isn’t as much of an issue anymore as I need to be patching changes that aren’t compatible with the child-theme model you use. i.e. modifying the mobile menu header files. Your documentation on child-theme supported overrides only works for td-standard, not td-composer.

td-composer/legacy/Newspaper/parts/menu-mobile.php

So I’ll copy over the style-buddypres.css into the parent with my edited version as part of the patching. There’s no rush for a response now on my behalf.

Knowing the correct way of doing this would be helpful for others in the future and maybe added to the child-theme documentation.

Thank you and have a nice day.

PFC
Participant
#0

Hello,

I’d like to make a number of changes to the BuddyPress stylesheet style-buddypress.css, I don’t see it being enqueued via functions.php so have no clue how it’s getting added.

If I copy the style-buddypress.css over to my child theme folder and make adjustments, this file won’t be loaded.

Please advise how are we supposed to use/adjust style-buddypress.css from within the child theme?

** all style changes and customizations must come from the child theme folder, I am not and won’t be adding anything to the “custom css” within the theme options.

Thank you,

Richard

DaveS
Participant
#0

Hi guys! Need some support!

I’m using version 9.5 of the Newspaper theme and I see that there’s an option to show or hide the sidebar on Woocommerce pages in the admin panel:

Template settings > WooCommerce template > Shop homepage + Archives

However I need to remove (not hide) the sidebar only from specific top-level archive pages via some code in functions.php or so… The sidebar has to stay on the child-level archives. How can I do this?

Thanks!

domino
Participant
#0

Hello,

I’ve uploaded the newest Newsmag theme (version 4.9.6) and overwritten the plugins we had using the ones that come in the zip file.
I’ve also uploaded the child theme (currently active).

Unfortunately none of them (main or child theme) seem to work in my site now.

The URL is the following (but first you’ll need to change your host file so farevela.net points to the IP: 31.47.77.24):
https://farevela.net/

The back office works but the front office shows the following error message:

Fatal error: Uncaught Error: Class ‘td_util’ not found in /srv/www/farevela.net/www/cms/wp-content/themes/Newsmag/functions.php:52 Stack trace: #0 /srv/www/farevela.net/www/cms/wp-includes/class-wp-hook.php(287): {closure}(false, Object(WP_Query)) #1 /srv/www/farevela.net/www/cms/wp-includes/plugin.php(212): WP_Hook->apply_filters(false, Array) #2 /srv/www/farevela.net/www/cms/wp-includes/class-wp.php(658): apply_filters(‘pre_handle_404’, false, Object(WP_Query)) #3 /srv/www/farevela.net/www/cms/wp-includes/class-wp.php(748): WP->handle_404() #4 /srv/www/farevela.net/www/cms/wp-includes/functions.php(1291): WP->main(”) #5 /srv/www/farevela.net/www/cms/wp-blog-header.php(16): wp() #6 /srv/www/farevela.net/www/index.php(19): require(‘/srv/www/fareve…’) #7 {main} thrown in /srv/www/farevela.net/www/cms/wp-content/themes/Newsmag/functions.php on line 52
There has been a critical error on this website.

Lines 47 to 58 of functions.php are these:

add_filter( ‘pre_handle_404’, function($param1, $param2) {

$post_id = url_to_postid(“http://&#8221;.$_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’]);
if (!empty($post_id)) {

$td_post_theme_settings = td_util::get_post_meta_array( $post_id, ‘td_post_theme_settings’ );
if ( is_array( $td_post_theme_settings ) && array_key_exists( ‘smart_list_template’, $td_post_theme_settings ) ) {
return true;
}
}
return $param1;
}, 10, 2);

Any advice welcome!
Thanks in advance.

Jose

Viewing 25 results - 101 through 125 (of 638 total)