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

Results from the Forum
Danny
Participant
#0

Hope this is ok to post here if not admin can delete it if prefered. My site scores 100 in the performance section using LiteSpeed Cache (wich is free) now i have a smal personal site so i also use the QUICKCloud CDN service wich is not too expensive (i put in 10 euros over a year a go and still have 3 euro left) this by itself already will boost your site speed by alot) but i wont dive into all the LiteSpeed Cache options and settings but it is a great free alternative.

So for those not using a expensive cache program like WPRocket that has a setting to preload your fonts but still would likle the benefits you can add a function to the theme’s functions.php file its best adviced to set up and do this on the Newsmag Child theme. This will also remove the font from ther Network dependency tree.

My site scored 100 already before i preloaded the font but it just adds up with all other optimizations so the Newsmag websites can really be blazing fast! DRiFT MAFIA Website

Just open the functions.php file in your prefered texteditor and ad this code at the bottom:
I could nott post the code for some reason probly safety
code

Page Speed Website

Calin
tagDiv Staff

Hi,
What you’re seeing is not a bug in the theme; it’s more of a WordPress core behavior that handles queries.
In WordPress, the ?p= parameter is normally used for post IDs (e.g. ?p=123). But:
– if the value is invalid (?p=test)
– and you’re already on a valid URL (like /page/15/)
WordPress simply ignores the invalid parameter instead of throwing a 404.

What you can do is to use a redirect plugin (s1). Install the plugin Redirection
Go to: Tools → Redirection
Add a new redirect:
– Source URL: /page/(.*)
– Query Parameters: p (match any value)
– Target URL: /page/$1
– Match: Regex (enable this option)
– Save the redirect
This will automatically remove ?p=anything from URLs and redirect to the clean version.

Another solution (s2) is to use a code in functions.php file (recomanded in a child theme)
function remove_invalid_p_parameter() {
if (isset($_GET['p']) && !is_numeric($_GET['p'])) {
wp_redirect(remove_query_arg('p'), 301);
exit;
}
}
add_action('template_redirect', 'remove_invalid_p_parameter');

Also, using a SEO plugin could help. These add canonical URLs, helping Google understand the correct page.

Calin
tagDiv Staff

Hi,
Unfortunately, there is no option in our theme to change/translate that text. Is possible to use code in the child theme functions.phphttps://wordpress.org/support/topic/change-shipping-to-delivery-across-plugin-generated-elements/

Calin
tagDiv Staff

Hi,
I think that you are referring to a similar small editor -> https://i.imgur.com/WK2rE82.pnghttps://prnt.sc/Gv6UZlWayxdX
In the most of the cases this problem can be fixed by adding an extra code, please set this code in functions.php -> wp-content/plugins/td-composer/legacy/Newspaper/functions.php or in functions.php in a child theme.

https://pastebin.com/NnMDZUXy

If the problem persists, please send us an email at contact@tagdiv.com and provide admin login. Include a link to this topic in the email. Let us know.
Let me know the results!
Thank you!

  • This reply was modified 5 months by Calin.
Calin
tagDiv Staff

Hi fuenson, I understand the situation.
Please do like this, use a child theme and in functions.php add this code:
add_filter('the_content', function($content) { return '<main role="main">' . $content . '</main>'; });
This should resolve the problem.
Let me know the results!

Calin
tagDiv Staff

Hi,
The code above was created specifically for the functions.php file of a child theme. I cannot guarantee that it will work exactly the same way when used as a code snippet it may work as is, but some adjustments could be required.
Even though this may not be the exact solution you requested, I made an effort to find a reliable alternative. While this falls outside the scope of the theme’s official support, I provided the most dependable option that can be reused by anyone through a child theme. I hope this proves helpful.

Calin
tagDiv Staff

Hi,
You can try the code from here: https://pastebin.com/UapDg6P0. This code is improved. It should be set inside the child theme in functions.php

Maddest
Participant
#0

Hello tagDiv Support Team,

I am experiencing a critical error on my website (running the Newspaper theme) specifically when performing a search. The rest of the site functions normally, but submitting a search query results in a “Critical Error” message.

Error Log Details:
I have enabled WP_DEBUG and identified the following fatal error:
Fatal error: Uncaught TypeError: Cannot access offset of type array on array in …/wp-content/plugins/td-composer/legacy/common/wp_booster/td_util.php:1196

Stack Trace Summary:

#0 td_util::get_template_id(Object(WP_Post)) called at td_util.php(340)
#1 td_util::check_header() called at td_wp_booster_functions.php(513)

The error seems to originate during the wp_enqueue_scripts and wp_head actions when the theme tries to determine the template ID for the search results page.

Environment Information:

Theme: Newspaper (using a child theme)

Plugin: tagDiv Composer

PHP Version: 8.4.13 (The error appeared after upgrading PHP versions)

WordPress Version: 3.9

The error only occurs on the search results page.

Is this a known compatibility issue with PHP 8.x and the current version of the tagDiv Composer? Could you please advise if there is a specific patch for td_util.php or if a plugin update is required to handle the array type-checking more gracefully in PHP 8?

Thank you for your assistance.

Website URL: madtrash.com

dataconurbano
Participant
#0

Hola, tengo la siguiente categoría: https://dataconurbano.net/category/categoria-prueba/

Quiero que se muestren 6 noticias por página y un paginador normal (numeros en la parte de abajo)

Hay forma de hacerlo desde el theme panel?

Buscando en internet encontré este codigo para functions.php del child theme. Me muestra el paginador y la cantidad correcta de noticias, pero en la página 2 me dice “Error 404”

add_action(‘pre_get_posts’, ‘personalizar_cat_544’);
function personalizar_cat_544($query) {

// Solo en el front-end y en el query principal
if (is_admin() || !$query->is_main_query()) {
return;
}

// Aplica SOLO en la categoría 544
if ($query->is_category(544)) {

// Cantidad de posts a mostrar
$query->set(‘posts_per_page’, 6);

// Asegurar que la paginación funcione correctamente
if ( get_query_var(‘paged’) ) {
$query->set(‘paged’, get_query_var(‘paged’));
}
}
}

Esa categoría tiene seteado:
Category template: Style 2
Category top posts style: Grid Full 1 (por css achiqué el tamaño de la imagen para que coincida con el container centrado)
ARTICLE DISPLAY VIEW: M10
Pagination style: Normal Pagination

Agradezco si me pueden ayudar

Muchas gracias

Calin
tagDiv Staff

Hi,
I think that you want to add the excerpt inside the post, if is so, then you need to use a shortcode since this element doesn’t exist in our builder:
The shortcode can be get from here:
https://wordpress.stackexchange.com/questions/336420/retrieving-post-excerpt-as-a-shortcode

add_shortcode( 'output_post_excerpt', 'get_the_excerpt' );

And it can be set in a child theme in functions.php the use the shortcode [output_post_excerpt]
to display the excerpt, this can be set on the single post template using tagDiv Composer in “Single External Shortcode” or text with title/column text elements.

I just tested and is working – https://i.imgur.com/qz1Zi42.pnghttps://i.imgur.com/7StOLec.pnghttps://i.imgur.com/Gtb8EdI.png&#8221;

Thank you!

mediax
Participant
#0

Hi there,

I recently Updated Newspaper theme. After update, i tested – all worked, besides search that gave an empty white screen. Doing some troubleshooting I noticed in console that an error 500 was thrown.

Looking at logs, i see this:

[21-Nov-2025 10:37:05 UTC] PHP Fatal error: Uncaught TypeError: Illegal offset type in /var/www/html/public_html/wp-content/plugins/td-composer/legacy/common/wp_booster/td_util.php:1196
Stack trace:
#0 /var/www/html/public_html/wp-content/plugins/td-composer/legacy/common/wp_booster/td_util.php(340): td_util::get_template_id()
#1 /var/www/html/public_html/wp-content/plugins/td-composer/legacy/common/wp_booster/td_wp_booster_functions.php(513): td_util::check_header()
#2 /var/www/html/public_html/wp-includes/class-wp-hook.php(324): td_load_css_fonts()
#3 /var/www/html/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#4 /var/www/html/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#5 /var/www/html/public_html/wp-includes/script-loader.php(2299): do_action()
#6 /var/www/html/public_html/wp-includes/class-wp-hook.php(324): wp_enqueue_scripts()
#7 /var/www/html/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#8 /var/www/html/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#9 /var/www/html/public_html/wp-includes/general-template.php(3192): do_action()
#10 /var/www/html/public_html/wp-content/plugins/td-standard-pack/Newspaper/header.php(11): wp_head()
#11 /var/www/html/public_html/wp-content/plugins/td-composer/td-composer.php(254): require_once(‘/var/www/html/p…’)
#12 /var/www/html/public_html/wp-includes/class-wp-hook.php(324): {closure}()
#13 /var/www/html/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#14 /var/www/html/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#15 /var/www/html/public_html/wp-content/themes/Newspaper/header.php(2): do_action()
#16 /var/www/html/public_html/wp-includes/template.php(810): require_once(‘/var/www/html/p…’)
#17 /var/www/html/public_html/wp-includes/template.php(745): load_template()
#18 /var/www/html/public_html/wp-includes/general-template.php(48): locate_template()
#19 /var/www/html/public_html/wp-content/themes/Newspaper-child/search.php(1): get_header()
#20 /var/www/html/public_html/wp-includes/template-loader.php(106): include(‘/var/www/html/p…’)
#21 /var/www/html/public_html/wp-blog-header.php(19): require_once(‘/var/www/html/p…’)
#22 /var/www/html/public_html/index.php(17): require(‘/var/www/html/p…’)
#23 {main}
thrown in /var/www/html/public_html/wp-content/plugins/td-composer/legacy/common/wp_booster/td_util.php on line 1196

Please could you offer me some advice on how to resolve this?

Thanks

Calin
tagDiv Staff

Hi,

The mentioned path was only if the mobile theme plugin was in use, if you are using the mobile page template, then there is no need to set the code in that path.

The shortcode where it is set, did you use a child theme to set it in functions.php? If so it should work, is working for me – https://i.imgur.com/mqFWgu0.png
Css – https://i.imgur.com/nt5jVHF.png
code -https://i.imgur.com/VA2JNSe.png

Thank you!

miciudadreal
tagDiv Member

Hi, here are the details:

– our blog incorrectly sets the “<meta name=’og:image’
vlaue=’uri_to_image’>” for the home page
– we want to force the value of the meta header “<meta name=’og:image’
value=’uri_to_custom_1image’>” only on the home page
– we don’t want to install a plugin for this
– we want to set the meta header with the functions.php (add_action)
– i don’t want theme updates (Newletter) to overwrite our custom functions . should i create a child theme from Newsletter just to add that function?

Calin
tagDiv Staff

Hi,
If all products will have the label with teh same procent then you cna use a hook.
use a child theme and set in functions.php file from child this function:
add_filter('woocommerce_sale_flash', 'woocommerce_custom_sale_text', 10, 3); function woocommerce_custom_sale_text($text, $post, $_product) { return '[NEW TEXT]'; }

The results – https://i.imgur.com/BOt46dS.pnghttps://i.imgur.com/TgFDO3R.png

#0

Subject: Excerpt Formatting Issue: Paragraph Breaks <p> tags are being stripped – Newspaper Theme
​Dear tagDiv Support Team,
​I am experiencing a persistent issue with my post excerpts (teasers) when they are displayed on my homepage and archive pages using your theme.
​The Problem:
​The theme is stripping out paragraph breaks (the <p> HTML tag) from the post excerpts, causing the text to be displayed as one single, dense block. This happens regardless of whether the excerpt is:
​Automatically Generated from the post content.
​Manually Entered in the “Excerpt” meta box.
​What I Have Tried (and failed with):
​Custom Excerpt: Writing manual excerpts with HTML tags (e.g., <p>Text</p>). The tags are still removed.
​Advanced Excerpt Plugin: I installed and configured the Advanced Excerpt plugin, ensuring the option to allow HTML tags was active. The theme seems to override the plugin’s functionality, and the paragraph breaks are still removed.
​My Question:
​Is there a specific setting within the Theme Panel, a tagDiv Composer Block setting, or a PHP filter that I can use in a Child Theme’s functions.php file to specifically allow the <p> tag (paragraph breaks) in the post excerpts displayed in your post listing blocks (like Flex Blocks)?
​I only need the paragraph formatting (<p>) to remain intact to improve readability.
​Thank you for your assistance.

Calin
tagDiv Staff

Hi,
Don’t edit theme LESS files.
Those variables are compiled before use, so changing them has no effect unless you rebuild the theme (not supported).

Use a child theme. Open your child theme folder and edit the style.css (or a new file like breakpoints.css), add:

/* Custom mobile breakpoint */

@media
(max-width: 575px) {
/* your mobile rules */
}

/* Between 576–767px (old mobile range) */

@media
(min-width: 576px) and (max-width: 767px) {
/* your tablet-like rules */
}

Make sure your CSS loads last.
In functions.php:

add_action(‘wp_enqueue_scripts’, function() {
wp_enqueue_style(‘my-breakpoints’,
get_stylesheet_directory_uri() . ‘/breakpoints.css’,
array(‘td-theme’), ‘1.0’);
}, 999);

Clear caches (theme + browser) and test at 575px width your new breakpoint now applies.
I hope this will help you!

rumosdabolsa
tagDiv Member

Hello Bettina,

I hope you are doing well.

I found the following code snippet within the theme files, which appears to define the responsive breakpoints:

CSS

/*
* responsive settings
*/

/* responsive landscape tablet */
@responsive_l_tablet_max: 1140px;
@responsive_l_tablet_min: 1019px;

/* responsive portrait tablet */
@responsive_p_tablet_max: 1018px;
@responsive_p_tablet_min: 768px;

/* responsive portrait phone */
@responsive_p_phone_max: 767px;
My question is about the mobile breakpoint, currently defined as $responsive_p_phone_max: 767px.

The theme’s default mobile layout works well on smaller screens (320px – 500px), but I feel the range up to 767px is too large and causes design issues on larger phones or in landscape mode. At 750px, for example, the layout looks stretched in mobile mode before transitioning to the tablet layout at 768px.

Question:

Considering that this code appears to be SASS/LESS and not pure CSS, what is the correct procedure to implement a change to this value?

Is there a functions.php filter or function in the child theme that would allow me to change the $responsive_p_phone_max value to something like 575px, or is it necessary to modify and recompile the SASS/LESS files?

Please Note:

I fully understand that any such modification is at my own risk and is not covered by support. I am aware of the potential impact.

I am using only the standard and mobile layouts integrated into the theme, and not the separate tagDiv Mobile Theme plugin.

I appreciate any guidance you can provide on the safest way to make this change.

Calin
tagDiv Staff

Hi,

For the issue related to the license key check, I recommend excluding that process from Redis object caching, you can try this code https://pastebin.com/PgCB3rap Please add this code to your child theme’s functions.php file.
If the issue persists, you can temporarily disable Redis during admin login as a fallback method to ensure access. This can help prevent lockouts when the licensing server is unreachable or when caching interferes with admin functionality.
if ( is_admin() && isset($_GET['redis_off']) ) {
define('WP_REDIS_DISABLED', true);
}

I have also notified a developer about this situation when he has time to check.

Thank you!

Calin
tagDiv Staff

Hi simchris,
Please try this code in .htaccess


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^CALIF/default-CAnewswire-800x600\.jpg$ - [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(?:gif|jpe?g|png|bmp)$ /CALIF/default-CAnewswire-800x600.jpg [L,NC]

If it is not working, you can try this code in functions.php in the child theme
add_filter('redirect_canonical', function($redirect_url, $requested) {
if (preg_match('/\.(gif|jpe?g|png|bmp)$/i', $requested)) {
return false; // stop WP from “guessing” a post for missing images
}
return $redirect_url;
}, 10, 2);

I hope one of those will work for you!

#0

Hello,

I’m using Newspaper with WooCommerce and trying to display a “Sold Out” badge/overlay on products that are out of stock.

I’ve already added hooks in my child theme’s functions.php (e.g. woocommerce_before_shop_loop_item_title and woocommerce_before_single_product_summary) but they don’t output anything, because Newspaper overrides the WooCommerce templates.

Could you please let me know:

Which Newspaper template file(s) handle the product loop and the single product layout so I can safely add my custom code in the child theme?

Is there a Newspaper-specific hook/action I should use to inject a “Sold Out” badge instead of standard WooCommerce hooks?

My goal: when a product is Out of Stock, show a <span class=”sold-out-overlay”>Sold Out</span> on the product thumbnail in the shop/category view, and on the featured image in the single product page.

Thanks in advance for clarifying the correct place to override/add this.

ghm33
Participant
#0

my website: https://newsbytes.ph

my problem: when i update to php8.3 from 7.4, i get this error:

Deprecated: Function create_function() is deprecated in /home/qesrqyjl/public_html/wp-content/themes/Newspaper-child/functions.php on line 41

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the td-cloud-library domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/qesrqyjl/public_html/wp-includes/functions.php on line 6121

i have already purchased a license just to ask this question in this forum.

Giport
Participant
#0

Hello, Simion!
1. Tell me, please, after disabling and even deleting the tagDiv Mobile Theme plugin, my website on mobile devices continues to show the title from the mobile theme, and sidebar blocks appear instead of the content. https://prnt.sc/Ekgttv5v4YeH
All caching plugins are disabled, and the plugin for the mobile theme has been removed. How can I return the site to its normal display?
Sample page: https://dev.giport.ru/news/society-news/lq-111-letnyaya-yaponka-katalas-na-velosipede-do-glubokoj-starosti

2. When the mobile theme is enabled, the forum is not displayed.: https://prnt.sc/x50-QgWRSGp1
How to make some categories https://dev.giport.ru/forum was it displayed on mobile devices in the regular version?
Maybe in a child theme in a file functions.php can I add some kind of hook?

3. Could you upload screenshots to your server on the forum? After a few months, the screenshots on prnt.sc they become unavailable. And you very often show solutions to problems there.

==================

1. Подскажите, пожалуйста, после отключения и даже удаления плагина “tagDiv Mobile Theme” мой сайт на мобильных устройствах продолжает показывать заголовок из мобильной темы, а вместо содержимого появляются блоки боковой панели https://prnt.sc/Ekgttv5v4YeH
Все плагины для кэширования отключены, а плагин для мобильной темы удален. Как я могу вернуть сайт к нормальному отображению?
Пример страницы: https://dev.giport.ru/news/society-news/lq-111-letnyaya-yaponka-katalas-na-velosipede-do-glubokoj-starosti

2. При включенной мобильной теме форум не отображается: https://prnt.sc/x50-QgWRSGp1
Как сделать, чтобы некоторые категории https://dev.giport.ru/forum отображалась на мобильных устройствах в обычной версии?
Может в дочернюю тему в файле functions.php можно добавить какой-то хук?

3. Не могли бы вы сделать на форуме загрузку скриншотов на ваш сервер? По прошествию нескольких месяцев скриншоты на prnt.sc становятся недоступными. А вы там очень часто показываете решения проблем.

jamie@gundigest.com
tagDiv Member

Hey Calin,

Yes, a developer modified functions.php of the parent theme and that was the issue. All modifications have been moved to the child theme and the child theme functions. Thank you for your help.

jamie@gundigest.com
tagDiv Member

Hi Calin,

Thank you for your response. The error did not resolve after following your suggestions. These are the steps I took.

– I verified I am using the latest Newspaper theme 12.7.1.
– I removed the child theme folder from wp-content/themes
– I refreshed the themes page in wp-admin to verify the theme was gone.
– I created Newspaper-child.zip from the theme package.
– I installed Newspaper-child.zip by uploading it into the WordPress admin panel. – WordPress said the installation was successful.
– I went back to the themes page and tried to preview the child theme.
– The same error showed.

2025/08/08 21:18:37 [error] 118#118: *1710 FastCGI sent in stderr: "PHP message: PHP Warning: require_once(/www/kinsta/public/mysite/wp-content/themes/Newspaper-child/blocks/acf-blocks-loader.php): Failed to open stream: No such file or directory in /www/kinsta/public/mysite/wp-content/themes/Newspaper/functions.php on line 644;

It is still looking for the /blocks/ folder in the child theme:

PHP message: PHP Fatal error: Uncaught Error: Failed opening required '/www/kinsta/public/mysite/wp-content/themes/Newspaper-child/blocks/acf-blocks-loader.php' (include_path='.:/usr/share/php') in /www/kinsta/public/mysite/wp-content/themes/Newspaper/functions.php:644

Thank you for any help you can provide.

theheritagelab
Participant
#0

Hello @Calin and team, in continuation to another post, I want to report another error I see on upgrading to PHP 8.2 – funnily, in a non-logged in view only.
Deprecated: Function WP_User_Query was called with an argument that is deprecated since version 5.9.0! who is deprecated. Use capability instead. in /home/customer/www/staging3../public_html/wp-includes/functions.php on line 6121
Problem seems to be with td_composer.
I also use a child theme… any idea what could solve this?

Viewing 25 results - 1 through 25 (of 638 total)