- NewspaperChild Theme Support
– Added plugins name code
– activated Speedbooster
– cleared cache
– run Pagespeed Insights and still showing scripts and CSS to move to footer
– tested functions.php
registered scripts
wpdreams-photostack | http://www.cele.si/wp-content/plugins/ajax-search-pro/js/nomin/photostack.js
jquery | http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
wpdreams-ajaxsearchpro | http://www.cele.si/wp-content/plugins/ajax-search-pro/js/min-scoped/jquery.ajaxsearchpro-noui-isotope.min.js
archivesCW | http://www.cele.si/wp-content/plugins/archives-calendar-widget/admin/js/jquery.archivesCW.min.js
td-site-min | http://www.cele.si/wp-content/themes/Newsmag/js/tagdiv_theme.min.js
comment-reply | /wp-includes/js/comment-reply.min.js
registered styles
wpdreams-asp-basic |
wpdreams-ajaxsearchpro-instances |
archives-cal-classiclight |
google-fonts-style | http://fonts.googleapis.com/css?family=Open+Sans:400,700
js_composer_front |
td-theme |
td-theme-child |
as I can see, styles are no longer with links as scripts are .. progress 🙂 but not for Pagespeed
-
This reply was modified 10 years by
gregy1403.
Hello larceny,
1) Here you can see the files that were changed in 6.6.3 version http://tagdiv.com/td_deploy/Newspaper/changed_files_6.6.2_6.6.3.html and in the version 6.6.4, the only file modified was the td_wp_booster_functions.php file found here: http://screencast.com/t/oNWcNnmvIh9M
2)If you want to do a child theme, you have to install the ultimate child theme that come bundled with our theme and let’s start to customize it. For more details about this, please check our documentation here: https://forum.tagdiv.com/the-child-theme-support-tutorial/
Hope this helps and let us know how it goes!
Thank you for the message!
As much as I hate plugins for stuff like this ….
you might temporarily try this to avoid “losing sales”…
https://wordpress.org/plugins/woocommerce-products-per-page/
but yes, this *should* work if you put it at bottom of your main (not child) theme functions.php file:
// Display 24 products per page. Goes in functions.php
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 24;' ), 20 );
Your version of code looks a little different than the official filter above, however.
REF:
https://docs.woothemes.com/document/change-number-of-products-displayed-per-page/
-
This reply was modified 10 years by
simchris.
Hi there,
I’ve noticed that the CSS and Javascript are loaded on every site page as well as other all other plugin’s CSS and JS. It’s resource wasting because it requires several TCP connections at every page load and degrading this way the site load performances and the user experience too. Therefore I’m trying to deregister CSS and Javascript where not needed and to load them only on pages where they are needed. For example, since the Contact Form 7 is used only on the ‘contacts’ page, I’ve added the following lines to Newsmag-child theme functions.php:
add_filter( 'wpcf7_load_js', '__return_false' );
add_filter( 'wpcf7_load_css', '__return_false' );
?>
Now, I should add the following lines in the page where the Contact Form 7 is used i.e. “contacts” page:
<?php
if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
wpcf7_enqueue_scripts();
}
if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
wpcf7_enqueue_styles();
}
?>
But I don’t have a “contacts.php” page! So that where I have to add this code?
More in general, could you advice a method by means of which I can always include CSS and JS (mainly due to plugins) only where needed?
Thanks in advance for any appreciated help.
Giuseppe
Hi
I’ve tested you’re code in child theme and works fine on my side: http://screencast.com/t/tdFHg1x6cI I am not sure why this code doesn’t work on your side but you can try to remove any other customizations from child theme, or also try to deactivate the child theme and insert the code in functions.php in parent theme.
Thanks!
I am trying to add a few custom image sizes inside the functions.php of the child theme. I add the code below and then run Regenerate Thumbnails on an image, but it doesn’t create any of my custom image sizes. I know the plugin is working because if I delete one of the existing thumbs, it recreates it.
Am I doing something wrong?
function custom_image_sizes() {
add_image_size("custom-thumb", 218, 125, true);
add_image_size("custom-large-thumb", 290, 166, true);
add_image_size("custom-medium", 532, 304, true);
add_image_size("custom-slider", 700, 400, true);
}
add_action('after_setup_theme', 'custom_image_sizes', 11);
Hi
I’ve test this code on my side an works fine: http://screencast.com/t/DspIZkQ2Yat4 Please check the code from line 26 in Newsmag-child/functions.php because seams to be a conflict there. Also try to deactivate the child theme and add the code in functions.php file from main theme, then check again.
Thanks!
Hi,
I use Contact Form 7 plugin in order to get the contact form (please see 43b.60a.myftpupload.com/contatti/). To avoid to get extra CSS and/or JavaScript file on every page of my site, I’ve followed this guide http://code.tutsplus.com/articles/optimizing-contact-form-7-for-better-performance–wp-31255. This way I should get the CSS and Javascript of Contact Form 7 plugin loaded only into the page where the form is really placed.
So that I’ve created a new functions.php file of my Newsmag-child theme which contains only the following code:
<?php
/*
GSM:file functions.php of the Newsmag-child theme
*/
if (!function_exists('aa_deregister_styles')) {
// Deregister Contact Form 7 styles
add_action( 'wp_print_styles', 'aa_deregister_styles', 100 );
function aa_deregister_styles() {
if ( ! is_page( 'contatti' ) ) {
wp_deregister_style( 'contact-form-7' );
}
}
}
if (!function_exists('aa_deregister_javascript')) {
// Deregister Contact Form 7 JavaScript files on all pages without a form
add_action( 'wp_print_scripts', 'aa_deregister_javascript', 100 );
function aa_deregister_javascript() {
if ( ! is_page( 'contatti' ) ) {
wp_deregister_script( 'contact-form-7' );
}
}
}
?>
But, after this I got the following error:
Warning: Cannot modify header information – headers already sent by (output started at /home/content/p3pnexwpnas10_data03/26/2630926/html/wp-content/themes/Newsmag-child/functions.php:26) in /home/content/p3pnexwpnas10_data03/26/2630926/html/wp-includes/pluggable.php on line 1207
What I’m doing wrong?
Thanks
Giuseppe
Hi Catalin,
Let’s see:
1. Js errors. Yes I had some errors with that, actually a lot, but I arrange it. The problem was on child theme (functions.php). Now all events with js seems to work properly.
2. I disabled all plugins except Visual Composer at first, and also updated theme to last version. Suddenly WordPress works great, so I started to enable plugins one by one and check if they cause some problems. Everything right (I didn’t enable WP-Rocket). I guessed problem was on there, but a couple hours late a new error 500 appeared on my screen.
I tell that because webpage works good during a couple of hours until crash again, maybe is a good hint for you to find out what’s happening on it.
3. I just followed your tutorial (except suhosin because my hosting doesn’t provide it). Let’s see how it works now, just after the changes have been made, web charges like lightning.
I hope this works fine, if it doesn’t, I would like share a couple of screencaptures with you because maybe some parameters on htacces o php.ini are causing the problem. For instance, php.ini had “memory_limit = 1024M
“.
I’ll track website to see if all works properly. Hope next time text us with good news.
Thanks Catalin.
Heh …. well, the short version would be … just install the main theme, don’t use child theme at all; don’t even upload it. (I don’t use child themes on ANY of our sites or client sites.) So, this way you have one set of things to optimize, manually minify, one set of functions, css, etc.
Just keep track of snippets with a map of which files/customizations you do. SO, when there is theme update you can paste in your functions.php changes into new file, for example; or if you mod the main style.css – make not of what you changed (e.g., search/replace default fonts). Use a good text editor with line numbering — so, you keep track of “I edited the hook at line 55 in file /theme/includes/td-whattheheck.php” etc.
Faster – no CSS redirect from child to parent; no mix of files, smaller to do backup of your site via FTP, blah blah blah.
So – that was short version. Long version would contain a lot of other commentary you don’t need to hear from me on this topic 😉
Just read you last post awtown about child theme being updated but it does not need to be. It is the theme that needs the update, not the child theme. Child theme is the same every theme update. Consists of functions.php and the css file.
If you are using the child theme then do the ftp overwriting the old theme with newer version way. You don’t have to delete the theme at all just unzip the new folder package and unzip theme folder and make sure you just upload the unzipped folder of the name with all the files of theme right over the older one on your server. It will just overwrite what is on your server.
Really, it is that easy. You don’t even have to deactivate the child theme this way either.
Hi Bogdan,
Many thanks, that’s worked great for the caption, although I’m still struggling with the pagination.
I’ve moved td_wp_booster_functions.php into my child theme (nested inside a wp_booster folder inside an includes folder, so the structure is the same) and made the edit you suggested, but I can’t see that it’s made any difference to the pagination options on the gallery.
I’m also trying to remove the lightbox from the tagdiv galleries; I removed this code from the same file, as was suggested in another thread:
http://screencast.com/t/OLjyKBFL
but it doesn’t seem to have stopped the lightbox from being used on tagdiv galleries – e.g. on this page: http://cogdiss.com/lisnew/draft-gallery-post/ – is there a stage I’m missing here?
Many thanks!
Hannah
Hi,
I am using Newspaper 6 Theme.
On category pages we have filter passed in query string which is post tag. So want to filter my posts according to that query string tag.
So I have changed query successfully which is effecting results of main category pages content. On loop.php modifying query with post tag make desired results. (In child theme)
But when it comes to top grid, it is hard-cord value of 5 passed there and if posts with tag are not present it displays nothing.
I found this piece of code which is calling Top grid :
<?php td_api_category_template::_helper_show_category_template() ?>
<?php td_api_category_top_posts_style::_helper_show_category_top_posts_style() ?>
And there is main function in File: /Newspaper/includes/wp_booster/td_wp_booster_functions.php
/* ----------------------------------------------------------------------------
* modify the main query for category pages
*/
add_action('pre_get_posts', 'td_modify_main_query_for_category_page');
function td_modify_main_query_for_category_page($query) {
//checking for category page and main query
if(!is_admin() and is_category() and $query->is_main_query()) {
//get the number of page where on
$paged = get_query_var('paged');
//get the filter_by
URL($_GET) variable
$filter_by = get_query_var('filter_by');
<strong> $query_tag = filter_input( INPUT_GET, 'tag', FILTER_DEFAULT );
if($query_tag)
$query->set('tag',$query_tag); /*<strong>I tried modifying query but it does not effect top posts*/</strong>
//get the limit of posts on the category page
$limit = get_option('posts_per_page');
// get the category object - with or without permalinks
if (empty($query->query_vars['cat'])) {
td_global::$current_category_obj = get_category_by_path(get_query_var('category_name'), false); // when we have permalinks, we have to get the category object like this.
} else {
td_global::$current_category_obj = get_category($query->query_vars['cat']);
}
//offset is hardcoded because of big grid
$offset = td_api_category_top_posts_style::_helper_get_posts_shown_in_the_loop();
//echo $filter_by;
switch ($filter_by) {
case 'featured':
//get the category object
$query->set('category_name', td_global::$current_category_obj->slug);
$query->set('cat', get_cat_ID(TD_FEATURED_CAT)); //add the fetured cat
break;
case 'popular':
$query->set('meta_key', td_page_views::$post_view_counter_key);
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
break;
case 'popular7':
$query->set('meta_key', td_page_views::$post_view_counter_7_day_total);
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
break;
case 'review_high':
$query->set('meta_key', td_review::$td_review_key);
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
break;
case 'random_posts':
$query->set('orderby', 'rand');
break;
}//end switch
// offset + custom pagination - if we have offset, WordPress overwrites the pagination and works with offset + limit
if(empty($query->is_feed)) {
if ( ! empty( $offset ) and $paged > 1 ) {
$query->set( 'offset', $offset + ( ( $paged - 1 ) * $limit ) );
} else {
$query->set( 'offset', $offset );
}
}
}//end if main query
}
While using Grid style one:
includes/shortcodes/td_block_big_grid_1.php
POST_LIMIT is passed as 5.
So is there any way that my category posts get filter by tag for top grid as well. I tried modifying main function as mentioned above. Please see this comment in code above (I tried modifying query but it does not effect top posts)
Please suggest how that will be possible.
Screen shot attached for details of URL having query string:
Hello,
So I tried to apply the same pagination answer from a Newsmag thread to Newspaper in order to have the numbers removed and display only “NEXT”/”PREVIOUS”. (I realized the screenshots are actually from a Newspaper theme)
However it doesn’t work. I looked at both files in Newsmag and Newspaper (td_module_single_base.php and td_wp_booster_functions) and in both cases the code regarding pagination is exactly the same.
It works when I use this tutorial on Newsmag and have the filter removed via functions.php in the child theme but it doesn’t work for Newspaper. Somehow Newspaper is forcing numbered pagination somewhere else.
Any ideas on solving this?
Thanks!
Hi,
I am using Newspaper in two blogs. In both I have using the Background Click Ad options with the same configuration.
In one it works ok in index:
http://foromoviles.com
And single:
http://foromoviles.com/la-garantia-de-los-moviles-mi-historia-con-lg/
But in the other it works in index:
http://faqsandroid.com/
But not in single:
http://faqsandroid.com/orange-dive-70/
I have tried changing:
- Child Theme
- functions.php
- Custom CSS
- ad links
But nothig works.
Can you help me?
Thanks in advance.
Hi,
Unfortunately the config file will not be included n child theme, as far I know, but if the developers will find a solution we will implement it.
You can try this hook in functions.php file from child theme to stop loading the default theme fonts, just paste this code in the child theme functions file – http://screencast.com/t/hLPMbut3GlOH – http://pastebin.com/HjBxAmTP
Thanks!
Hi,
Thanks for suggestion, it is on our list and we will try to find a solution for this.
An alternative if you use child theme would be to add this code in functions.php file(from child theme) – http://screencast.com/t/hLPMbut3GlOH – http://pastebin.com/HjBxAmTP
Hope this helps!
Hi alin
add_action('td_global_after', 'hook_td_global_after');
function hook_td_global_after() {
td_global::$default_google_fonts_list = array ();
}
The above code does not remove Google fonts. Once i applied the above code via child theme functions.php file, still Google fonts are applied across the website.
Where it is went wrong?
Due to all the security changes this year in WP, which are ongoing (Akismet identified this week as major security issue, allowing commenters to hack your site!), the best plan is this:
a) make changes to the core theme files (not child theme)
b) keep track of changes made, files, line number, code snippets changed where
c) to update, download new theme version, apply your mods to same files, replace old theme folder with the new version with your replicated mods;
d) if something fails, go back to the backup
Not much TagDiv or anybody can do about ongoing security patches to the Visual Composer plugin — TagDiv doesn’t make that, nor do the theme devs around the world bundling that as groovy cool way to do page layouts.
Sadly, WordPress and all the pieces which fit together have been going through major upheaval this year — and it’s good for security, but seriously you have to get annoyed when the anti-spam tool causes your site to be hacked from comments containing “emojis” which you can’t disable in WP without adding code to the functions.php file. Sheesh.
Anyway– just some feedback. Wasn’t trying to annoy or shoot you down, just some feedback that it’s not just you; WP has been a pain in the arse this year.
I’m counting something like 100+ updates since Spring on some of our sites for WP, Akismet, Yoast, Visual Composer, etc., due to security vulnerabilities. Wild.
Okay,
I forgot to mention that I’m currently using the Child Theme (as we’ve added a few customisations to the footer and functions.php)! I activated the main theme and found that the Featured Images have returned. I also discovered that deactivating all of the plugins (but Visualiser) caused the site to white-screen, so we’re looking into that at the moment.
It seems it’s entirely likely that some code we added to the Child Theme files have conflicted with the Featured Image. We’ll do some digging and update the post accordingly. Alternatively, I could send over the Child Theme files (via the email address you provided) to discuss things in more detail?
Hello to everyone.
I just installed child theme like 3 days ago.
i have take it from parent theme only these:
1)style.css
2)functions.php
3)comments.php
4)header-style1.php
My web site is: http://www.storypickers.com
I dont’t have any problem or something like that, but i was wondering do i need to take more files
from the parent theme?
For example if i want to modify any code or something to my web site, they tell my to put a code at header.php
But i don’t have a header.php. So, i need to take the header.php and put it at my child theme, or i need to put the code inside to the parent them to header.php???
Waiting for your reply wish to you king regards
I activated the child theme, but when I enter my customization in the file functions.php I get a fatal error php on the site …
here’s the code that I add after the basic template functions.php on child
// funzioni personalizzate
// Setup Admin Thumbnail Size
if ( function_exists( 'add_theme_support' ) ) {
add_image_size( 'admin-thumb', 100, 999999 ); // 100 pixels wide (and unlimited height)
}
// Thumbnails to Admin Post View
add_filter('manage_posts_columns', 'posts_columns', 5);
add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2);
function posts_columns($defaults){
$defaults['my_post_thumbs'] = __('Img Evid');
return $defaults;
}
function posts_custom_columns($column_name, $id){
if($column_name === 'my_post_thumbs'){
echo the_post_thumbnail( 'admin-thumb' );
}
}
add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
function new_mail_from($old) {
return 'news@cinefilos.it';
}
function new_mail_from_name($old) {
return 'Cinefilos.it';
}
add_filter( 'jpeg_quality', create_function('', 'return 50;' ) );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
add_filter('deprecated_constructor_trigger_error', '__return_false');
// fine funzioni personalizzate
thank you 🙂
Hi
I want to use your child theme and have read your doc here
https://forum.tagdiv.com/the-child-theme-support-tutorial/
so basically I just use FTP to make a folder name “newspaper-child”, upload functions.php and style.css under your zip file/code/newspaper-child and then done?
do I need to activate it from anywhere at mydomain.com/wp-admin ?
Can i overwrite functions.php using child theme? Do i simply copy the function to the existing functions.php in the newspaper-child folder or do i have to use theme api?
RESOLVED … after inserting code to functions.php, you have to visit front page to get the right list above.
This should be clearified in instructions. For example I am using custom functions plugin, becouse I don’t wanna edit theme files, and I just dont like to use child themes. 🙂