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
@wpscholar
wpscholar / schema-api.php
Created May 30, 2018 20:25
Plugin for creating a post type with a custom API that reflects Schema.org data structures
<?php
/*
* Plugin Name: Schema API
* Plugin URI:
* Description:
* Version: 0.1.0
* Author: Micah Wood
* Author URI: https://wpscholar.com
* License: GPL2
@koskinenaa
koskinenaa / wordpress-filter-custom-post-types-by-custom-taxonomies.php
Last active November 16, 2020 12:15
Add filtering by custom taxonomies to a post type. Note when registering the custom taxonomies 'query_var' should not be set to false. If so, this function won't work,
/**
* Add taxonomy filtering to custom post types
*
* Original example for one post type, https://generatewp.com/filtering-posts-by-taxonomies-in-the-dashboard/
*
*/
function filter_cpt_by_taxonomies( $post_type, $which ) {
// Affected post types
$post_types = array(
'my_post_type',
@ashokmhrj
ashokmhrj / show-meta-data-in-admin-list.php
Last active May 6, 2020 15:23
Showing feature image in admin post listing
/**
* WordPress
* Showing feature image in admin post listing
*/
add_filter('manage_posts_columns' , 'ask_custom_columns');
/*add_filter('manage_{post-type-slug}_posts_columns' , 'ask_custom_columns');*/
function ask_custom_columns( $columns ) {
$columns = array(
@MaximeCulea
MaximeCulea / array-multidimensional-key-search
Created April 12, 2018 14:52
Recursively key search into a multidimensional array
@codytooker
codytooker / acf-sync-user-and-cpt-bidirectional-relationship.php
Created January 18, 2018 21:27
Modified version of the bidirectional relationship function to help facilitate users to cpt relationships
<?php
/*
* This code is modified from the original here
* https://github.com/Hube2/acf-filters-and-functions/blob/master/acf-reciprocal-relationship.php
*
* Some comments may not be useful anymore since the modifications
*/
@LukaHarambasic
LukaHarambasic / functions.php
Last active August 8, 2021 10:32
Wordpress: ACF-Field as CPT Title
// inspired by: https://gist.github.com/rveitch/9018669face1686e74aaa68026856f36
// add title to CPTs which don't provide a title (useful for the relationship field (https://www.advancedcustomfields.com/resources/relationship/))
function sync_acf_post_title($post_id, $post, $update) {
$post_type = get_post_type($post_id);
// check for the current CPT
if($post_type === "cpt_name_1") {
@MaximeCulea
MaximeCulea / required-excerpt.php
Last active June 6, 2020 21:32 — forked from microneer/gist:abe764ae031e88c5b0919b661a0c8ff9
Make post excerpt as mandatory field with capability to set the lenght, if needed.
// put this in functions.php or in your custom plugin or theme code.
$m = new Mandatory_Excerpt();
$m->add('post', 20 ); // will require all 'post' post types to have an excerpt at least 20 characters long
/**
* Helper class which removes specified metaboxes from specified pages. It manages setting up the hooks
* and calling them.
*
* @author: Michael Fielding
*
@MaximeCulea
MaximeCulea / move-post-excerpt-before-content.php
Last active June 6, 2020 21:33
Move the post excerpt before the post content.
<?php add_action( 'edit_form_after_title', 'mc_post_excerpt_meta_box_before_content' );
/**
* Move the post excerpt before post content
*
* @param $post
*
* @author Maxime CULEA
*/
function mc_post_excerpt_meta_box_before_content( $post ) {
@sabrina-zeidan
sabrina-zeidan / query_meta_without_value.php
Last active May 27, 2020 03:11
meta_query to search post without custom field (no matter whether its empty or doesn't exist at all [WordPress]
$getposts = get_posts( array(
'numberposts' => -1,
'post_type' => 'post',
'post_status' => 'any',
'fields' => 'ids',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'custom_field',
'compare' => 'NOT EXISTS',
@rodrigoborgesdeoliveira
rodrigoborgesdeoliveira / ActiveYouTubeURLFormats.txt
Last active October 18, 2025 02:30 — forked from ScottCooper92/gist:ea11b690ba4b1278e049
Example of the YouTube videos URL formats
http://www.youtube.com/watch?v=-wtIMTCHWuI
http://youtube.com/watch?v=-wtIMTCHWuI
http://m.youtube.com/watch?v=-wtIMTCHWuI
https://www.youtube.com/watch?v=lalOy8Mbfdc
https://youtube.com/watch?v=lalOy8Mbfdc
https://m.youtube.com/watch?v=lalOy8Mbfdc
http://www.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
http://youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail
http://m.youtube.com/watch?v=yZv2daTWRZU&feature=em-uploademail