Skip to content

Instantly share code, notes, and snippets.

@dannyfoo
dannyfoo / functions.php
Created April 11, 2022 09:14
Add post thumbnail to Elementor post navigation
<?php
// Source: https://github.com/elementor/elementor/issues/3863#issuecomment-643794411
// Previous next post thumb
add_filter('previous_post_link', 'sydney_child_post_nav_thumbnail', 20, 5 );
add_filter('next_post_link', 'sydney_child_post_nav_thumbnail', 20, 5 );
function sydney_child_post_nav_thumbnail($output, $format, $link, $post, $adjacent) {
if( !$output ) {
@dannyfoo
dannyfoo / functions.php
Created February 24, 2022 06:37
Restrict email domains in FluentForms
/**
* Source: https://fluentforms.com/docs/limit-email-domains-in-fluent-forms-form-submission/
**/
add_filter('fluentform_validate_input_item_input_email', function ($error, $field, $formData, $fields, $form) {
/*
* add your accepted domains here
* Other domains will be failed to submit the form
*/
@dannyfoo
dannyfoo / elementor.css
Last active April 27, 2022 09:04
Elementor snippets
/**
* Force the feature image to occupy post image space in Cards layout
* Choose 1 of the solutions below which suits your scenario
**/
/* if the elementor-fit-height class exists */
.elementor-post__thumbnail.elementor-fit-height img {
height: 100% !important;
width: auto !important;
}
@dannyfoo
dannyfoo / functions.php
Created December 21, 2021 08:50
Customizations for default WordPress password protected pages / posts
<?php
// Add a custom class to the body for password posts / pages only
function add_password_protected_body_class( $classes ) {
if ( post_password_required() )
$classes[] = 'wp-password-page';
return $classes;
}
add_filter( 'body_class', 'add_password_protected_body_class' );
@dannyfoo
dannyfoo / functions.php
Created December 15, 2021 07:20
Add and display custom fields to WP Store Locator listing template and info window template
function custom_meta_box_fields( $meta_fields ) {
$meta_fields[__( 'Additional Information', 'wpsl' )] = array(
'phone' => array(
'label' => __( 'Tel', 'wpsl' )
),
'fax' => array(
'label' => __( 'Fax', 'wpsl' )
),
'email' => array(
@dannyfoo
dannyfoo / functions.php
Last active November 6, 2021 06:55
WordPress function: Duplicate page without plugin
<?php
/*
* Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
*/
function rd_duplicate_page_as_draft(){
global $wpdb;
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'rd_duplicate_page_as_draft' == $_REQUEST['action'] ) ) ) {
wp_die('No post to duplicate has been supplied!');
}
@dannyfoo
dannyfoo / functions.php
Last active November 6, 2021 06:55
WordPress function: Duplicate post without plugin
<?php
/*
* Function for post duplication. Dups appear as drafts. User is redirected to the edit screen
*/
function rd_duplicate_post_as_draft(){
global $wpdb;
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'rd_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
wp_die('No post to duplicate has been supplied!');
}