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 / dwpb-example-filter-author-archive-post-types.php Disable Blog Example: Add new post types to author archives. By default only posts are shown on author archives, if other post types are to appear on the author archives, pass them with this filter.
<?php
add_filter( 'dwpb_author_archive_post_types', 'dwpb_example_filter_author_archive_post_types', 10, 1 );
/**
* Example: Filter `dwpb_author_archive_post_types` for Disable Blog plugin.
*
* Add new post types to author archives.
*
* By default only posts are shown on author archives, if other post types are to appear
* on the author archives, pass them with this filter.
*
@dgoze
dgoze / multilingualpress-cross-post-type.php
Created May 2, 2025 23:43 — forked from joshuadavidnelson/multilingualpress-cross-post-type.php
Filter the MultilingualPess admin metabox to allow for connecting translations to other post types on remote site.
<?php
/**
* Filter the post search arguments allow for cross-post-type connections.
*
* @param array $args the WP_Query arguments used.
* @return array
*/
function remote_post_search_arguments( $args ) {
$translated_post_types = array( 'post', 'page', 'product' );
@dgoze
dgoze / cpt_has_archive.php
Created May 2, 2025 23:39 — forked from joshuadavidnelson/cpt_has_archive.php
Check if a custom post type supports archives
<?php
/**
* Check if post type supports an archive
*
* @param string $post_type post type name
* @uses get_post_type
* @global object $post
* @returns boolean
* @author Joshua David Nelson
*/
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;?>">