Skip to content

Instantly share code, notes, and snippets.

View mrdulal's full-sized avatar
:octocat:
Targeting the things.

Sanjaya Dulal mrdulal

:octocat:
Targeting the things.
View GitHub Profile
@mrdulal
mrdulal / gist:77740a4e7d41c20bc0a10536e3e65f25
Last active February 3, 2020 11:00
Repeatable Custom Fields in a Metabox
/**
* 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 December 6, 2016 08:02
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.
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 December 6, 2016 08:02
Mandatory WordPress for custom post type and all post as well as page.
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');
}