Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Targeting the things.

Sanjaya Dulal mrdulal

:octocat:
Targeting the things.
View GitHub Profile
@mrdulal
mrdulal / gist:77740a4e7d41c20bc0a10536e3e65f25
Last active Feb 3, 2020
Repeatable Custom Fields in a Metabox
View gist:77740a4e7d41c20bc0a10536e3e65f25
/**
* Repeatable Custom Fields in a Metabox
* Author: Sanjaya (Fendora Bhai)
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
/*function hhs_get_sample_options() {
$options = array (
@mrdulal
mrdulal / mandatory excerpt wordpress
Created Dec 6, 2016
Mandatory WordPress for custom post type and all post as well as page. Remove if ( 'custom-post-type-slug' != $data['post_type'] ) { } else { } for all excerpt mandatory.
View mandatory excerpt wordpress
function mandatory_excerpt($data) {
//for multiple custom post type just add && 'custom-post-type-slug' != $data['post_type']
if ( 'custom-post-type-slug' != $data['post_type'] ) {
} else {
$excerpt = $data['post_excerpt'];
if (empty($excerpt)) {
if ($data['post_status'] === 'publish') {
add_filter('redirect_post_location', 'excerpt_error_message_redirect', '99');
}
@mrdulal
mrdulal / mandatory excerpt wordpress
Created Dec 6, 2016
Mandatory WordPress for custom post type and all post as well as page.
View mandatory excerpt wordpress
function mandatory_excerpt($data) {
//for multiple custom post type just add && 'custom-post-type-slug' != $data['post_type']
if ( 'custom-post-type-slug' != $data['post_type'] ) {
} else {
$excerpt = $data['post_excerpt'];
if (empty($excerpt)) {
if ($data['post_status'] === 'publish') {
add_filter('redirect_post_location', 'excerpt_error_message_redirect', '99');
}