Skip to content

Instantly share code, notes, and snippets.

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

Daniel dgoze

💭
I may be slow to respond.
View GitHub Profile
function mattrad_remove_script_version( $src ){
return remove_query_arg( 'ver', $src );
}
add_filter( 'script_loader_src', 'mattrad_remove_script_version' );
add_filter( 'style_loader_src', 'mattrad_remove_script_version' );
@dgoze
dgoze / acf_map_fallback.php
Created March 27, 2025 18:17 — forked from mattradford/acf_map_fallback.php
ACF Google Map static image, for fallback
<img src="http://maps.google.com/maps/api/staticmap?center=<?php echo $location['lat']; ?>,<?php echo $location['lng']; ?>&markers=<?php echo $location['lat']; ?>,<?php echo $location['lng']; ?>&zoom=9&size=360x300&sensor=FALSE" />
<div class="acf-map--mobile" style="background-image:url('http://maps.google.com/maps/api/staticmap?center=<?php echo $location['lat']; ?>,<?php echo $location['lng']; ?>&markers=<?php echo $location['lat']; ?>,<?php echo $location['lng']; ?>&zoom=9&size=360x300&sensor=FALSE');"></div>
@dgoze
dgoze / cpt_no_slug.php
Created March 27, 2025 18:17 — forked from mattradford/cpt_no_slug.php
Remove slug from CPT
// Remove slug from CPT
// Careful of collisions and permalink must be %postname%
// http://www.itsabhik.com/remove-custom-post-type-slug/
// There was an error in the code after $args array: , not ;
// See also http://colorlabsproject.com/tutorials/remove-slugs-custom-post-type-url/
function remove_cpt_slug( $post_link, $post, $leavename ) {
$args = array(
'public' => true,
@dgoze
dgoze / parent_template_switch.php
Created March 27, 2025 18:16 — forked from mattradford/parent_template_switch.php
Switch template based on page parent or grandparent. Requires the page parent template is set.
// Switch template based on page parent or grandparent. Requires the page parent template is set.
add_action('template_include', 'auto_child_template');
function auto_child_template( $template = '' ) {
global $post;
if ( ! is_page() ) {
return $template;
}
else {
@dgoze
dgoze / gallery_post_thumbnail.php
Created March 27, 2025 18:15 — forked from mattradford/gallery_post_thumbnail.php
Set post thumbnail from gallery. Saves a performance hit.
function set_featured_image_from_gallery() {
$has_thumbnail = get_the_post_thumbnail($post->ID);
if ( !$has_thumbnail ) {
$images = get_field('gallery', false, false);
$image_id = $images[0];
if ( $image_id ) {
set_post_thumbnail( $post->ID, $image_id );
@dgoze
dgoze / ACF Post Meta - Terms.php
Created March 27, 2025 17:14 — forked from besimhu/ACF Post Meta - Terms.php
Get ACF fields from taxonomy without using ACF functions.
<?php
// get taxonomy
$taxonomy = get_term_by( 'slug', get_query_var( 'taxonomy_name' ), 'my_custom_taxonomy' );
$acf_field = get_option( 'my_custom_taxonomy_' . $taxonomy->term_id . '_acf_field_slug' );
<?php
global $current_user;
$userID = $current_user->ID;
$imageArray = get_field('your_picture', 'user_' . $userID);
$imageThumbURL = $imageArray['sizes']['thumbnail'];
?>
<img src="<?php echo $imageThumbURL;?>">
@dgoze
dgoze / acf-to-excerpt.php
Created August 15, 2024 23:50 — forked from groupewibi/acf-to-excerpt.php
[WordPress Plugin] Copy ACF field to Post Excerpt
<?php
/**
* Plugin Name: ACF Field to Excerpt
* Plugin URI: http://wordpress.stackexchange.com/q/70990/12615
*/
function acf_to_excerpt(){
$post_type = 'post';
$field = 'summary';
@dgoze
dgoze / index.html
Created August 15, 2024 23:46 — forked from vielhuber/index.html
confetti success animation #js
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5, minimum-scale=1" />
<title>.</title>
<script>
class Confetti {
constructor() {
this.confettiConfig = {