Skip to content

Instantly share code, notes, and snippets.

View melissajclark's full-sized avatar

Melissa Jean Clark melissajclark

View GitHub Profile
@melissajclark
melissajclark / functions.php
Last active March 19, 2024 19:23
WordPress sub-menu JS: turn [a href="#"] links into <button> and more
<?php
/**
* Enqueue the JS file.
*
* @since 1.0.0
*
* @return void
*/
function clientname_styles_and_scripts() {
@melissajclark
melissajclark / body-class.php
Created November 18, 2022 17:27
Filter the body_class to add classes to site <body> in specific scenarios
/**
* Set Header Colour on pages based on first block's colour
*
* @link https://developer.wordpress.org/reference/functions/body_class/
*/
function cwce_header_body_classes( $classes ) {
// page header colours
if ( is_page() && !is_page( 'Blog' ) ) {
@melissajclark
melissajclark / block-editor.js
Last active May 19, 2023 15:24
WordPress Block Editor: Add a custom Query block variation with a Post Template
/**
* Include variable for ImageDateTitle icon from core. Used in the Query Block Variation below
*/
const external_wp_element_namespaceObject = window["wp"]["element"];
const external_wp_components_namespaceObject = window["wp"]["components"];
const imageDateTitle = (0, external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 48 48"
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
@melissajclark
melissajclark / woocommerce.php
Last active May 26, 2019 16:34
Customize WooCommerce email to show membership card
<?php
/**
*
* Template: customer-completed-order.php
*
* Customize the email to include a member card.
*
* @link https://businessbloomer.com/woocommerce-check-product-id-order/
*
*/
@melissajclark
melissajclark / remodal.php
Last active July 11, 2017 14:28
Remodal example
<?php $modalID = basename(get_permalink()); ?>
<div class="teamMember">
<?php the_post_thumbnail('teamMember'); ?>
<h4><?php the_title(); ?></h4>
<a href="#<?php echo $modalID;?>"><?php _e('Read Bio', 'wp-theme-name'); ?></a>
<div class="remodal teamMemberBio" data-remodal-id="<?php echo $modalID;?>">
<button data-remodal-action="close" class="remodal-close"></button>
@melissajclark
melissajclark / custom taxonomy
Created April 20, 2017 15:21
taxonomy example
/**
*
* Register Line Sizes Taxonomy
*
**/
function trends_line_sizes_taxonomy() {
$labels = array(
"name" => __( 'Line Sizes', 'trends'),
@melissajclark
melissajclark / woocommerce.php
Created April 3, 2017 15:57
woocommerce page with sections for product categories
<?php
/**
* The WooCommerce Template
*
* This is the template that displays all WooCommerce pages by default.
*
* @package THEMENAME
*/
get_header(); ?>
@melissajclark
melissajclark / header.php
Last active June 14, 2016 17:41
Example - different header for pages.
<?php // Reference: https://codex.wordpress.org/Conditional_Tags
// Use conditional PHP tags to ouput different content based on the template in use?>
<?php if ( is_page ) ) : // check if we are on a page ?>
<?php // code here for display on pages ?>
<?php else : // code below runs if we are NOT on a page ?>
<?php // code here displays on anything that is NOT a page ?>
@melissajclark
melissajclark / hero.php
Last active May 12, 2016 14:59
Random Hero Image Example
<?php
$images = get_field('hero_home_images');
if( $images ):
shuffle($images); // randomizes the image array
$max = 1; // set the max here;
$count = 0; // current count
?>
<?php
foreach( $images as $image ):
$count++; // increment count
@melissajclark
melissajclark / style.css
Created April 13, 2016 13:45
CSS for Simply Nicole's website
/* This will style the default page titles just like the category page titles */
.page .entry-title {
font-size: 13px;
letter-spacing: 1px;
color: #ffffff;
background-color: #000000;
margin-bottom: 0px;
padding: 5px 0px;
text-align: center;