Swap WordPress “Widget Area” based on Page Template

WOW! well, it would seems as tho i figured it out! after MORE searching, i came across https://learn.wordpress.org/lesson-plan/widget-areas apparently i had to “register” a “sidebar” – which thru me, as i was wanting to modify in the footer. after looking that up, the term “sidebar” is used anywhere the theme allows the user to add … Read more

delete_term is not working properly with add_action()

AFAIK, slug is unique. So $post_cat_term = get_term_by( ‘slug’, $deleted_term->slug, ‘category’ ); shouldn’t return anything. Instead, you may try name. Also, delete_term callback gets 5 parameters, so it’s better to adjust that accordingly. See if the following works: function delete_similar_term( $term_id, $tt_id, $taxonomy, $deleted_term, $object_ids ) { if( $deleted_term->taxonomy === ‘movies_category’ ) { $post_cat_term = … Read more

Auto updating JavaScript dependancy in functions.php

If I understood your question correctly, you have two JavaScript files: ads.js and banner.js. You want the site to load the updated version of both of these files, whenever any of these files are changed. If this understanding is correct, then you may do the following: function my_custom_theme_scripts() { $ads_version = filemtime( get_stylesheet_directory() . ‘/js/ads.js’ … Read more

How to enqueue Bootstrap 4.6 js & css from local files

This answer was given on the main StackOverflow platform wp_enqueue_script( ‘bootstrap-js’, get_template_directory_uri() . ‘/js/bootstrap.min.js’, array( ‘jquery’ ), ‘4.6.0’, true); wp_enqueue_style( ‘bootstrap-css’, get_template_directory_uri() . ‘/css/bootstrap.min.css’, array(), ‘4.6.0’, ‘all’ ); The supplied code has been tested and works as expected

How to overwrite image if it already exists – WordPress, Gravity form

These lines of code and can help you to overwrite image $attachment_id = get_post_thumbnail_id($post_id); wp_delete_attachment($attachment_id, true); if(isset($file) && !empty($file) ){ $upload_overrides = array(‘test_form’=> false); $movefile = wp_handle_upload($file, $upload_overrides); $filename = basename( $movefile[‘url’] ); $wp_filetype = wp_check_filetype($filename, null ); $attachment = array( ‘guid’ => $wp_upload_dir[‘url’] . “https://wordpress.stackexchange.com/” . $filename, ‘post_mime_type’ => $wp_filetype[‘type’], ‘post_title’ => preg_replace(‘/\.[^.]+$/’, ”, … Read more