I like More Lang plugin because there are no duplicate pages and posts for other language versions in the admin panel. But I had a problem – for the banners on the home page (which are embedded in the theme) there was no way to change the texts dynamically, depending …
Read More »How to add 301 redirect to https for Yii2 without .htaccess
I’ve tested different redirect options for .htaccess, but sites keep giving “redirected you too many times” error. Here is the working code to solve the problem. In the file /config/web.php you need to find: 'bootstrap' => [ 'log', 'app\components\Bootstrap', ], and place below: 'on beforeRequest' => function ($event) { if(!Yii::$app->request->isSecureConnection){ …
Read More »How to hide any blocks when submitting Contact Form 7
Forms can easily be hidden after they’ve been filled out and submitted, because the form gets a class sent when submitted. But there are lot of cases when you need to hide blocks that are placed outside of this form, but which are logically related to the form. If you …
Read More »How to display page/post content in WordPress theme
This case is relevant for cases when you need to display all the content of a particular page in a template. Below is an example PHP include for implementation. <?php $post1 = get_post( 100500 ); $text = $post1->post_content; // post content echo apply_filters('the_content', $text); // output content ?> Instead of …
Read More »Setting up JSHint for Vscode
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 »Missing write access to /usr/local/lib/node_modules when installing Jshint for Vscode
The problem is described in the topic. Below is a screenshot of this error: Here is the solution, you just need to change the permissions: sudo chown -R $USER /usr/local/lib/node_modules After that npm install -g jshint and any npm install works fine.
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 find changed files in console
Relevant for Linux, macOS. This article lists commands that help you find files that have changed over a certain period. 1. Find all modified files in the current folder in order of freshness of changes. The most recent will be on top: find ./c -type f -printf '%TY-%Tm-%Td %TT %p\n' …
Read More »