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
@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 = {
@dgoze
dgoze / functions.php
Created August 15, 2024 23:31 — forked from groupewibi/functions.php
ACF OEmbed with thumbnails
<?php
/* Pull apart OEmbed video link to get thumbnails out*/
function get_video_thumbnail_uri( $video_uri ) {
$thumbnail_uri = '';
// determine the type of video and the video id
$video = parse_video_uri( $video_uri );
// get youtube thumbnail
@dgoze
dgoze / getTaxTermsByOtherTaxTerm.php
Created August 15, 2024 23:28 — forked from vovadocent/getTaxTermsByOtherTaxTerm.php
Get Taxonomy Terms By Other Taxonomy Term
<?php
function getTaxTermsByOtherTaxTerm($taxonomy_args, $out_taxonomy, $post_type = NULL) {
global $wpdb;
$tax_q = $taxonomy_ids = array();
$post_type_q = !empty($post_type_q) ? "AND p.post_type = '$post_type'" : "";
foreach ($taxonomy_args as $tax => $term_id) {
$sql = "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt
INNER JOIN $wpdb->term_taxonomy t ON (t.term_id = tt.term_id AND tt.taxonomy = '$tax' AND t.term_id = $term_id)";
$taxonomy_ids = array_merge( $taxonomy_ids, $wpdb->get_col($sql) );
<?php
/* filter to get "services" in product categories, child categories, and singe product pages correctly */
// /services/%product_cat%/ - Product base permalink settings
// services - Product Category base permalink settings
add_filter('rewrite_rules_array', function( $rules ) {
$new_rules = array(
'services/([^/]*?)/page/([0-9]{1,})/?$' => 'index.php?product_cat=$matches[1]&paged=$matches[2]',
'services/([^/]*?)/([^/]*?)/page/([0-9]{1,})/?$' => 'index.php?product_cat=$matches[2]&paged=$matches[3]',
'services/([^/]*?)/?$' => 'index.php?product_cat=$matches[1]',
@dgoze
dgoze / add_files_to_zip.php
Created August 15, 2024 23:27 — forked from vovadocent/add_files_to_zip.php
Add Files to Zip
<?php
$files = array('file1.txt', 'file2.csv', 'file3.png');
$zip = new ZipArchive();
$zip_name = "out/" . time() . ".zip"; // Zip name
$zip->open($zip_name, ZipArchive::CREATE);
foreach ($files as $path) {
if (file_exists($path)) {
$zip->addFromString(basename($path), file_get_contents($path));
} else {
<?php
add_filter( 'post_type_archive_link', 'fix_post_type_archive_link', 10, 2 );
function fix_post_type_archive_link( $link, $post_type ) {
if($post_type == 'scripts'){
$link = str_replace('/%some-slug%', '', $link);
}
return $link;
}