Skip to content

Instantly share code, notes, and snippets.

View chekle's full-sized avatar

Cheyne chekle

View GitHub Profile
@chekle
chekle / gist:6ecdc9d2cf479ea1bd71848d6d633eb4
Created September 7, 2023 04:31
Alternating layouts ACF / PHP
<?php $counter = 0; if(get_sub_field('timeline')): ?><?php while(has_sub_field('timeline')): ?>
<?php if ($counter % 2 === 0) :?>
<?php else: ?>
<?php endif; ?>
<?php $counter++; endwhile; ?><?php endif; ?>
@chekle
chekle / gist:3a0b1cea4392ce03f45a925d77c1de30
Created September 5, 2023 23:30
Custom SwiperJS navigation arrows using font awesome
.swiper-button-prev{
&:after{
font-family: "Font Awesome 5 Pro";
content:'\f060';
font-weight:100;
color:$alpha;
}
}
.swiper-button-next{
&:after{
<?php if ( wp_is_mobile() ) : ?>
/* Display and echo mobile specific stuff here */
<?php else : ?>
/* Display and echo desktop stuff here */
<?php endif; ?>
@chekle
chekle / gist:90140926d2b9e6b848a01849896a5a20
Created August 14, 2023 23:21
ACF Repeater Field Odd / Even layouts
<?php $counter = 0; if(get_sub_field('timeline')): ?>
<?php while(has_sub_field('timeline')): ?>
<?php if ($counter % 2 === 0) :?>
<?php else: ?>
<?php endif; ?>
<?php if(get_sub_field('select_banner_image_or_video') == 'Banner Image') { ?>
<?php } else { ?>
<?php } ?>
<?php if(get_sub_field('') == '') { ?>
<?php } else if(get_sub_field('') == '') { ?>
@chekle
chekle / gist:56895de79bfea13474208fb0b3d4e91b
Created July 16, 2023 22:37
Background Images - Examples Using CSS & ACF
style="background-image:url('<?php $image = get_sub_field('image'); $size = 'full'; if( $image ) { echo wp_get_attachment_image_url( $image, $size ); } ?>');"
style="background-image: linear-gradient(269.77deg, rgba(0, 0, 0, 0.2) 2.1%, rgba(0, 0, 0, 0.6) 100%), url(<?php $image = get_sub_field('background_image'); $size = 'full'; if( $image ) { echo wp_get_attachment_image_url( $image, $size ); } ?>);"
/* Background Images CSS */
background-image:url(images/image.jpg);
background-repeat: no-repeat;
background-size:cover;
background-position:center;
/* Custom shortcode button function */
add_shortcode( 'action-button', 'action_button_shortcode' );
function action_button_shortcode( $atts ) {
extract( shortcode_atts(
array(
'title' => 'Title',
'url' => ''
),
$atts
));
@chekle
chekle / gist:4c9c9eacfd4601003a2d51840b76ad4b
Created July 12, 2023 03:28
WordPress Register Custom Post Type & Taxonomy
function my_custom_post_projects() {
$labels = array(
'name' => _x( 'Projects', 'post type general name' ),
'singular_name' => _x( 'Project', 'post type singular name' ),
'add_new' => _x( 'Add New', 'Project' ),
'add_new_item' => __( 'Add New Project' ),
'edit_item' => __( 'Edit Project' ),
'new_item' => __( 'New Project' ),
'all_items' => __( 'All Projects' ),
'view_item' => __( 'View Project' ),
@chekle
chekle / gist:650b144d5c2eae85c689e8e74c47335f
Created July 12, 2023 03:19
WordPress Custom Permalink Structure
/news/%postname%/
This puts /news in front of any 'post'
@chekle
chekle / gist:5d7934e2bc9fe559cd53ce0dddc05a57
Created July 6, 2023 06:48
WordPress Shortcode Examples
WORDPRESS DO SHORTCODE
<?php echo do_shortcode("[shortcode]"); ?>
SHORTCODE FROM ACF FIELD
<?php echo do_shortcode(get_field('social_stream_shortcode')); ?>
GFORMS
<?php echo do_shortcode("[gravityform id='1' title='false' description='false' ajax='true']"); ?>
[gravityform id="1" title="false" description="false" ajax="true"]