Skip to content

Instantly share code, notes, and snippets.

@ianhoyte
ianhoyte / blog-pagination.html
Last active November 22, 2021 22:21
Better HubSpot Pagination. This pagination snippet has been taken and modified from Jason Rosa's "Numbered Blog Pagination" snippet: https://designers.hubspot.com/code-gallery/entry/us/dontgojasonwaterfalls-blog-numbered-pagination
{% if contents.total_page_count > 1 %}
<div class="blog-pagination">
{% set page_list = [-2, -1, 0, 1, 2] %}
{% if contents.total_page_count - current_page_num == 1 %}{% set offset = -1 %}
{% elif contents.total_page_count - current_page_num == 0 %}{% set offset = -2 %}
{% elif current_page_num == 2 %}{% set offset = 1 %}
{% elif current_page_num == 1 %}{% set offset = 2 %}
{% else %}{% set offset = 0 %}{% endif %}
@ianhoyte
ianhoyte / shortcode_within_a_shortcode.php
Created February 4, 2020 20:39
Shortcode within a shortcode
/**
* wps_nested_shortcodes_products_display
*
* Place this in functions.php
*/
function wps_nested_shortcodes_products_display( $atts ) {
$a = shortcode_atts( array(
'types_shortcode' => '',
'show_featured_only' => '',
@ianhoyte
ianhoyte / wps_rewrite_post_type_args.php
Last active January 31, 2020 19:59
Rewrite the WP-Shopify (https://wpshop.io/) post types to retain their permalink structure if a custom post type structure is set.
<?php
/**
* wps_rewrite_post_type_args
*
* Retains the permalink structure if a custom permalink structure is
* set within Wordpress.
*
* @param array $args Wordpress post type arguments.
* @param string $post_type The post type's slug.
* @param array $settings The plugin settings data pulled in from the DB.