Skip to content

Instantly share code, notes, and snippets.

Add the following to your `functions.php`
```php
function vc_before_init_actions() {
require_once( get_template_directory().'/functions/shortcodes/vc-text-image.php' );
}
add_action( 'vc_before_init', 'vc_before_init_actions' );
```
And now create a file in the location specified above with the following (customise accordingly):
```
/**
* Display categories or products view
*
* If the display type (set in product categories in WP) is set to "standard", add a div with categories so that it can
* be styled. Else, use the set display type value as the class
*/
add_action('woocommerce_before_shop_loop', function(){
$current_term = get_queried_object();
$display_type = get_term_meta( $current_term->term_id );
Taken from here https://code.tutsplus.com/tutorials/understanding-the-walker-class--wp-25401
```
class Walker_Simple_Example extends Walker {
// Set the properties of the element which give the ID of the current item and its parent
var $db_fields = array( 'parent' => 'parent_id', 'id' => 'object_id' );
// Displays start of a level. E.g '<ul>'
// @see Walker::start_lvl()
function start_lvl(&$output, $depth=0, $args=array()) {
```
<?php
/**
* Add generic tracking code to all pages except "Thank you" page
*/ ?>
<!-- Global site tag (gtag.js) - Google Ads: 734634785 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);}
gtag('js', new Date()); gtag('config', 'AW-XXXXXXXXXXX');
## Working locally
https://www.shopify.com/partners/blog/95401862-3-simple-steps-for-setting-up-a-local-shopify-theme-development-environment
## Basics
### Conditional
```
{% if user.name == 'elvis' %}
Hey Elvis
{% endif %}
WP cron hooks are stored in the options table in an option named cron. WooCommerce likes to fill this over time until it is too big to write.
While not perhaps optimal, what I do is just empty it:
```
UPDATE wp_2_options SET option_value = '' WHERE option_name = 'cron'
```
Extract from unencrypted PFX
```
openssl pkcs12 -in [file.pfx] -out keys_out.txt
```
Extract from encrypted PFX
```
openssl pkcs12 -in [file.pfx] -out keys.pem -nodes
```
```
dig mydomain.com
```
```
$args = array(
'post__in' => $ids,
'post_type' => array(
'post',
'featured_item', // Include for its tag archive listing.
),
'numberposts' => -1,
'meta_key' => 'custom_post_date',
'orderby' => 'meta_value',
Ensure src attribute of video is empty. Then add something like this:
```
<script>
window.onload = function(){
document.getElementById("vidSrc").src = "mysrc.mp4";
document.getElementById("vid").load();
document.getElementById("vid").play();
};
</script>