As it often happens, we do not need product SKU where it is placed in the template. To display in the right place, use this code: <?php echo '' . $product->sku . ''; ?> When I published this code on a test project (in /woocommerce/single-product/short-description.php) as a result, the product …
Read More »How to display all attributes of a Woocommerce product
Often I need to display all the attributes of a product in another place in the template, not in a separate tab with characteristics. To solve this case, use the following code: <?php global $product; $product->list_attributes(); ?>
Read More »How to display the Woocommerce product title in a theme
The product name in WooCommerce is no different from the title of the post in the Posts and Pages. Therefore, to display the WooCommerce product name anywhere in the template, add the code: <?php the_title(); ?>
Read More »How to display the Nextgen Gallery
On this page I publish shortcodes to insert into an article, or into a template. Option 1 – default: [ngg src="galleries" ids="1" display="basic_thumbnail" thumbnail_crop="0"] Option 2 – show multiple galleries: [ngg src="galleries" ids="1,3" display="basic_thumbnail" thumbnail_crop="0"] Option 3 – displaying images by tags: [ngg src="tags" ids="primertega" display="basic_thumbnail" thumbnail_crop="0"] Option 4 – …
Read More »Canonical for pagination in Opencart below version 3
Pagination pages may not have canonicals at all by default. To add their automatic generation, open the file /catalog/controller/product/category.php and in it after the line $this->load->model(‘tool/image’); add the following code: if (isset($this->request->get['page'])) { $page = $this->request->get['page']; $pathx = explode('_', $this->request->get['path']); $pathx = end($pathx); $this->document->addLink($this->url->link('product/category', 'path=' . $pathx ), 'canonical'); } …
Read More »Redirect 301 from https to http
This is one of the examples of the implementation of redirection from https to http. RewriteEngine on RewriteCond %{HTTP:HTTPS} =on [NC] RewriteRule ^(.*)$ http://domainname/$1 [R=301,L]
Read More »Include the file and generate title
It happens that the generated data is stored in a separate file. And the task is to output, for example, titles with a preliminary check of already existing values (not empty) in a third-party file. An example of the implementation is below: <?php include($_SERVER['DOCUMENT_ROOT']."/seo.php"); if(isset($seoh1) AND $seoh1!='') { echo $seoh1; …
Read More »How to make a PDF file available for download
If you do not need to make PDF files available for viewing, but want to publish them only for download, you can immediately register the property so that then the files will be downloaded immediately. Example: <a download="" class="tda-link gradient-text" href="/docs/file.pdf">Download PDF file</a>
Read More »Remove page=2 from canonical links for Opencart 3
The developers decided that in Opencart 3+ for SEO it would be very useful to add a link to the current page as canonical, even if it is a pagination page. This is an awful SEO solution, so you need to make some changes. So, you need: from <link href=”https://domain/path?page=2 …
Read More »Title for bitrix pagination
I will not describe why this is necessary, I will only publish a ready-made solution. else echo $APPLICATION->ShowProperty("meta_title"); if (isset($_GET['PAGEN_1']) && $_GET['PAGEN_1']!=1) { echo " Page ".$_GET['PAGEN_1']; } if (isset($_GET['PAGEN_2']) && $_GET['PAGEN_2']!=1) { echo " Page ".$_GET['PAGEN_2']; } if (isset($_GET['PAGEN_3']) && $_GET['PAGEN_3']!=1) { echo " Page ".$_GET['PAGEN_3']; } The disadvantage …
Read More »