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
<?php
/**
* Plugin Name: ThriveDX Custom Post Types
* Description: Registeres custom post types used by the ThriveDX website
*
*
*/
/**
* Disabled and used the CPT UI plugins already installed
@Archie22is
Archie22is / functions.php
Created May 16, 2024 13:34
Working example of a WordPress Loop Shortcode
<?php
/**
*
*
*/
if (!function_exists('footer_get_latest_post')) {
function footer_get_latest_post() {
ob_start();
$footerPost = '';
$args = array('posts_per_page' => 1 );
@Archie22is
Archie22is / loadmore.php
Last active May 13, 2024 12:33
Load more posts
<?php
/**
* Display courses using a shortcode
* @author Archie M
*
*
*/
function short_courses_loop( $atts ) {
// Extract shortcode attributes
@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 / 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 / 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;