Skip to content

Instantly share code, notes, and snippets.

@morgyface
morgyface / acf_image_to_featured_image.php
Created April 8, 2020 19:54
WordPress | Set ACF image to be the WP feature image
@loorlab
loorlab / even_odd_display_repeater_acf_WP.php
Created March 30, 2019 06:19
Even / Odd Display with Repeater ACF Field - WordPress
<div class="level customers level-wrapper">
<ul class="categories">
<?php if( have_rows('items_page_block') ): ?>
<?php while( have_rows('items_page_block') ): the_row();
// vars
$image_item_block = get_sub_field('image_item');
$title_item_block = get_sub_field('title_item');
$text_item_block = get_sub_field('text_item');
if( get_row_index() % 2 == 0 ){ ?>
@jenhuls
jenhuls / acf_field_in_shortcode.php
Last active October 22, 2020 11:26
[ACF Text Field for Shortcode] #ACF #WordPress #shortcode
// This allows a shortcode to be used in an ACF text field.
<?php
$revslider_shortcode = get_field( 'revolution_slider_shortcode' );
echo do_shortcode($revslider_shortcode);
?>
@jenhuls
jenhuls / ADynamicCSSStyleSheet.md
Last active October 22, 2020 11:23
[Dynamic CSS in WordPress using ACF Options] #WordPress #ACF

USING ADVANCED CUSTOM FIELDS OPTIONS TO CREATE A DYNAMIC STYLESHEET IN WORDPRESS

Creating a dynamic stylesheet instead of just dumping CSS into the head of WordPress is cleaner, faster and just better all around. It gives the ability for colors to be chosen by the client or the intern but keeps the code in the theme much neater.

It's very simple to implement in just 3 easy steps:

  1. Add a custom function to one of your custom functions.php files (I like to keep mine separate) that converts PHP to CSS
  2. Write your PHP "CSS" file just like you would a CSS file except you can use ACF custom field values for your CSS
  3. Enqueue your dynamic stylesheet

The stylesheet only updates/adds custom style content on "Options" update.

@eudesgit
eudesgit / class-acf-image-upload.php
Last active January 31, 2023 14:40
WordPress - Uploading images to Advanced Custom Fields (AFC)
<?php
class ACF_Image_Upload {
public $post_id;
function update_acf ( ) {
$attach_id = $this->get_image_attach_id('my-image.jpg');
// Saving image

Hardening WordPress

Securing WordPress using a combination of configuration changes and plugins.

.htaccess and wp-config.php tasks

1. Add keys to wp-config.php

2. Hide .htaccess and wp-config.php

@ndunk28
ndunk28 / mixins.scss
Last active March 26, 2022 12:51
mixins
@mixin clearfix() {
&:after {
content: " ";
display: table;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
@gokulkrishh
gokulkrishh / media-query.css
Last active August 16, 2025 10:19
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active July 24, 2025 16:11
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*