Skip to content

Instantly share code, notes, and snippets.

View Archie22is's full-sized avatar
💭
I may be slow to respond.

ᴀʀᴄʜɪᴇ ᴍᴀᴋᴜᴡᴀ™ Archie22is

💭
I may be slow to respond.
View GitHub Profile
@Archie22is
Archie22is / function.php
Created March 21, 2024 23:09
Content type related post excerpt in WordPress (Not Clean)
<?php
function new_excerpt_more($more) {
global $post;
$current_post_type = get_post_type();
if($current_post_type == 'case_study'):
return '<a href="'. get_permalink($post->ID) . '"><i class="fa fa-arrow-circle-o-right"></i> Read the case study</a>';
endif;
if($current_post_type == 'post'):
@Archie22is
Archie22is / hubspot_breadcrumbs.html
Last active March 6, 2024 21:22
Simple "hacky" HubSpot blog breadcrumb
<div id="blog--breadcrumbs">
<ul>
<li>
<a href="/" class="">Home</a>
</li>
{% if is_listing_view %}
<span class="nav--spacer">&#x203A;</span>
<li>
<strong><span class="no--link">Insights</span></strong>
</li>
@Archie22is
Archie22is / functions.php
Created June 23, 2023 15:04
Remove WordPress menus
<?php
function remove_item_from_menu() {
remove_menu_page( 'edit.php?post_type=elementor_library' ); // removes elementor addons , menu item added by plugins
remove_menu_page( 'edit-comments.php' ); // removes comment menu
remove_submenu_page('themes.php', 'theme-editor.php'); // remove submenu called theme edititor inside appearance
remove_submenu_page('themes.php', 'widgets.php'); // removes widgets submenu
}
add_action( 'admin_init', 'remove_item_from_menu' );
@Archie22is
Archie22is / functions.php
Created June 11, 2023 11:00
Disable certain prodicts from being sold based on a custom ACF date field.
<?php
/**
*
*
*
*/
function set_end_order_date ( $is_purchasable, $product ){
// Set time zone
//$timezone = date_default_timezone_set('Europe/London');
@Archie22is
Archie22is / javascript.js
Created April 17, 2023 04:12
Fix gap on a Wordpress theme, which uses jetpack masonry and imagesloaded lazyload.
/**
* Add or try this in file masonryInitializer.js
* Source: https://github.com/desandro/imagesloaded/issues/303
*
*/
(function ($) {
"use strict";
@Archie22is
Archie22is / functions.php
Created April 12, 2023 12:00
Unlist, index and redirect - WooCommerce Shit
<?php
/**
* Hide specific prohects
* @author Archie M
*
*/
function piglet_remove_posts_from_home_page( $query ) {
if( $query->is_main_query() && $query->is_home() ) {
$query->set( 'post__not_in', array( 1027335, 1027302, 1027259 ) );
@Archie22is
Archie22is / mail.php
Created November 19, 2020 05:27
Filters images for RSS feed (Erik Teichmann)
/**
* Filters images for RSS feed--makes thumbs go through large; large images resize down to MailChimp friendly width.
* Add this to your functions.php file WITHOUT the opening php
*
* Author: Erik Teichmann, minor tweaks by Robin Cornett
* Author URI: http://www.eriktdesign.com/
*/
// Add filters for RSS
add_filter('the_excerpt_rss', 'et_change_thumbs', 20); // changes the excerpt for rss
@Archie22is
Archie22is / functions.php
Created February 9, 2023 08:55
Set all WooCommerce product prices as "POA"
<?php
/**
* Set all WooCommerce product prices as "POA"
* @author Archie M
*
*/
function poa_product_price_display( $price ) {
$price = 'POA';
return $price;
}
@Archie22is
Archie22is / funtions.php
Created January 13, 2023 10:50
WordPress Modify HTML functions - Drop this in your functions.php
<?php
function start_modify_html() {
ob_start();
}
function end_modify_html() {
$html = ob_get_clean();
$html = str_replace( 'Next Project', 'Next Offer', $html );
$html = str_replace( 'Previous Project', 'Previous Offer', $html );
echo $html;
@Archie22is
Archie22is / test.php
Created December 13, 2022 13:46
Php CURL Test
<?php
///////////////////// TESTING VARS
//$endpoint = 'https://dev.admin.englishwoodlandstimber.co.uk/api/sale/stock-list';
//$secred = '46a4632d3d68173d2bea3dc684f82e70604704bf08817d6cb2fe959ca07768d8';
$ch = curl_init($endpoint);
$headers = [];
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);