How would I go about replacing this function in my child theme located in inc/template-tags.php

How would I replace this function that lies inside inc/template-tags.php in my parent theme

function theme_navigation() { ?>                  <div id="theme-nav-container">             <nav id="site-navigation" class="main-navigation">                 <?php wp_nav_menu( array('theme_location' => 'theme-studios-primary', 'menu_class' => 'sf-menu', 'fallback_cb' => false, 'walker'  => new theme ) ); ?><div class="clearfix-pro"></div>             </nav>             <div class="clearfix-pro"></div>         </div>                  <!-- close #theme-nav-container -->                   <?php } 

There is no add action that it is hooked on to, there is no check to see if the function already exists. How would I replace it without touching the parent theme. I have removed much of the code in the function for brevity but I think it still makes sense.

Thanks ahead of time

Randomizing wp_tag_cloud() in child theme

I’m trying to write a wordpress function code in my child theme that randomizes the words in the word cloud where previously it was alphabetized.

The code Im using is below, which doesn’t work.

// add_filter('wp_tag_cloud_args', 'my_wp_tag_cloud_args_filter'); function my_wp_nav_menu_args_filter($  args) {     $  args['order'] = 'RAND';     // do something     return $  args; } // 

I’m able to update the wp_tag_cloud()’s default (‘Order’ = ‘RAND’) args in wp-includes/category-template.php but I know that any changes will get replaced. The change work when in that file.

How can I move those set of changes to my wordpress child theme?

Child theme stylesheet not reflecting the changes

I have created a child theme and the website is showing up properly with the activated child theme. I made some changes in the child theme’s php files for adding two controls in the child theme’s Appearance –> Customize section which will add a button ("Download my cv" button) on the home page. To do this I have added two php files and made modifications in them, keeping the same folder structure as the parent theme. They are working perfectly locally but not on the server. Although in localhost I have made the changes directly on the parent theme files.

I also can see the child theme’s style sheet is loading by view source but on making modification in the style sheet its not showing the changes. Whereas any modification in functions.php is working. Some help would be appreciated. Please check the screenshots. Thanks changes in localhost on parent theme working fine but changes in the child theme on server not working

How to change only one javascript function in wordpress child theme?

I would like to change just one JavaScript function in the child theme but without having to insert all the JavaScript code of the parent theme.

How do I change only this function (I need change only count = Math.ceil(width / size) line):

function slickAutoResponsive(slider, max, size) {    if (!max){     max = 5;   }   if (!size){     size = 380;   }    var width = slider.width(),     count = Math.ceil(width / size);    if (count < 1) count = 1;   if (count > max) count = max;    return count; } 

How to write a file from a theme to the “Site Address” directory?

I recently came across a theme which creates a sitemap and attempts to add it to the Site Address directory/root, so https://example.com/sitemap.xml. I believe the way this theme does it makes some bad assumptions about file paths and uses ABSPATH.

$  fp = fopen( ABSPATH . 'sitemap.xml', 'w' ); fwrite( $  fp, $  sitemap ); fclose( $  fp ); 

In most cases, this might work without incident. However, I’m actually using Bedrock which means sitemap.xml ends up in https://example.com/wp/sitemap.xml with /wp/ added and so visiting the expected URI (https://example.com/sitemap.xml) results in a 404.

I’d like to correct this via a child theme or by PR but I frankly have no clue where to begin, so I’ve currently just made some symlinks, but something tells me there’s a more thorough approach.

Imagify / Image Optimization for theme inline div background?

I’m using the imgaify plugin to serve webp images. Using their plugin a normal tag ends up looking like this:

<picture class="attachment-large size-large wp-post-image"> <source type="image/webp" srcset="https://.../image.jpg.webp 870w, https://.../image-300x128.jpg.webp 300w" sizes="(max-width: 870px) 100vw, 870px"> <img width="870" height="372" src="https://.../img.jpg" alt="Questions? We Can Help" srcset="https://.../image.jpg 870w, https://.../image-300x128.jpg 300w" sizes="(max-width: 870px) 100vw, 870px"> </picture> 

This works fine and well for normal img tag replacement. Here is where i am running into issue:

On some of the pages, my custom theme grabs the featured image and sets this image to the background of a DIV inline with CSS. No optimization is applied here heavily weighing down the page size.

I’m unsure what the best approach would be to fix this:

  1. Create a custom function that returns the optimized jpg/png version of the featured image and return that?

  2. Create a custom function that will spit out the webp version of the file (does one exist?) then use something like monderizr to detect webp support and display the correct styles?

I’m not currently using modernizr so adding another script may outweigh any speed gains. Is there a simpler solution?

Here is how my theme generates the code for the featured image:

<?php if ( has_post_thumbnail() ) : ?> <div class="innerpage-banner" style="background:url(<?php $  src = wp_get_attachment_image_src( get_post_thumbnail_id( $  post->ID ), 'full', false ); echo esc_url( $  src[0] ); ?>) no-repeat; background-size:cover; background-position: center center;"> <?php else: ?>     ... <?php endif; ?>