Friday , December 20 2024

Webmaster notes

301 redirect to https via WordPress function

I don’t remember why I needed this solution at all, most likely because of infinitive redirects after editing .htaccess file. Below is a redirect option via functions.php: function force_https () { if ( !is_ssl() ) { wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 301 ); exit(); } } add_action ( 'template_redirect', 'force_https', …

Read More »

301 redirect to https for WordPress multisite

The multisite mode in this case is when the main domain and its subdomains work in the same base and the subdomains are a mirror of the main site. If I add a standard 301 redirect to .htaccess then subdomains via http subdomains start redirecting to the main site. This …

Read More »

Display video instead of preview in K2 Joomla category

The task is to display a video instead of a preview of the K2 material in the general output of materials in the category. here wrote about how to display a video from YouTube instead of a picture of the K2 material inside the material. To display images in categories, …

Read More »

Display video instead of preview in K2 Joomla material

The task is to display a video from YouTube on the K2 material page instead of the uploaded image. The output of the image on the site is like this: <?php if($this->item->params->get('itemImage') && !empty($this->item->image)): ?> <!-- Item Image --> <div class="itemImageBlock"> <span class="itemImage"> <a class="modal" rel="{handler: 'image'}" href="<?php echo $this->item->imageXLarge; …

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 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

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 »