Saturday , February 22 2025

Webmaster notes

Setting up JSHint for Vscode

Vs Code

Here is an example of the contents of the .jshintrc file (it should be inside the project, or in the project folder). { "camelcase" : true, // Variable names in camelCase style "undef" : true, // All non-global variables must be declared before they can be used "quotmark" : true, …

Read More »

How to add widget for WordPress

You must first make an area for displaying the widget through the admin panel, then connect the widget in the template file. For the first part, use the code and place it in the template’s functions.php. register_sidebar(array( 'name' => 'newwidgetblock', // name of the area in admin panel 'id' => …

Read More »

Display categories above product list for WooCommerce

To display categories above the list of products, you need to enable this checkbox in the WooCommerce settings, but then the categories will be displayed the same as the products, there will be no separator between categories and products. The following code makes it possible, with the “Show products only” …

Read More »

How to allow HTML tags in WordPress category description

By default, the engine cuts out all HTML tags, and with them the content that we write in the description field for WordPress categories. To teach WordPress to understand tags, you need to add the following code to the functions.php file: remove_filter('pre_term_description', 'wp_filter_kses'); remove_filter('pre_term_description', 'wp_kses_data'); By the way, to add …

Read More »

How to randomly display multiple words using PHP

Without long preliminary explanations, I am posting the working code here. <?php $input = array("test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10"); $rand_keys = array_rand($input, 5); echo $input[$rand_keys[0]] . ", "; echo $input[$rand_keys[1]] . ", "; echo $input[$rand_keys[2]] . ", "; echo $input[$rand_keys[3]] . ", "; echo $input[$rand_keys[4]] …

Read More »

ACF not showing up in WooCommerce categories

By default, ACF fields can be displayed like this: <?php the_field('slogan');?> or like this: <?php if( get_field("slogan") ): ?> <?php the_field( "slogan" ); ?> <?php else :?> Custom text if needed. <?php endif; ?> In WooCommerce, this construction does not work, below are correct code example: $queriedObject = get_queried_object(); echo …

Read More »