- ID: Unique identifier for the post.
- post_author: ID of the post's author.
- post_date: Date and time of post publication.
- post_date_gmt: Date and time of post publication in GMT.
- post_content: Full content of the post.
- post_title: Title of the post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When the plugin is activated, schedule a weekly event for a specific task | |
function custom_plugin_activate() { | |
// Check if the event isn't already scheduled | |
if (!wp_next_scheduled('custom_task_hook')) { | |
// Schedule a weekly event using WordPress cron | |
wp_schedule_event(time(), 'weekly', 'custom_task_hook'); | |
} | |
// Call the function to perform the task immediately upon activation | |
perform_custom_task(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hook to the post insertion action, to trigger a notification on certain post types | |
add_action('wp_insert_post', 'notify_admin_for_new_post', 10, 3); | |
function notify_admin_for_new_post($post_id, $post, $update) | |
{ | |
// Check for a specific custom post type and if the post is being published for the first time | |
if ($post->post_type == 'custom_post_type' && $post->post_status == 'publish' && empty(get_post_meta($post_id, 'check_if_run_once'))) { | |
// Initialize variables | |
$organizer = ''; | |
$post_title = get_the_title(); // Assuming it's the title of the post |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//You can use this to load the values from checkboxes in a Formidable form. | |
//In Formidable Forms for WordPress, when you want to retrieve the values of checkboxes using the frm_after_create_entry hook, | |
//you need to access the form entry data that's passed to your hook function. | |
//This hook is triggered after an entry is created, and it provides you with all the submitted data. | |
add_action('frm_after_create_entry', 'get_checkbox_values', 30, 2); | |
function get_checkbox_values($entry_id, $form_id){ | |
// Check if it's the specific form you want (replace 123 with your form ID) | |
if ($form_id == 123) { | |
// Get the entry object | |
$entry = FrmEntry::getOne($entry_id, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#sortable-area { | |
width: 100%; | |
min-height: 50px; | |
border: 1px solid #ccc; | |
padding: 10px; | |
} | |
.sortable-item { | |
margin: 10px; | |
padding: 5px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_logout_redirect( $redirect_to, $requested_redirect_to, $user ) { | |
// Array of roles and their respective redirect URLs | |
$role_redirects = array( | |
'administrator' => home_url( '/admin-page/' ), | |
'editor' => home_url( '/editor-page/' ), | |
// Add other roles and their redirects here | |
); | |
// Check if user data is available | |
if ( isset( $user->roles ) && is_array( $user->roles ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function resize_uploaded_image($file_path, $max_width, $max_height) { | |
$image = wp_get_image_editor($file_path); | |
if (!is_wp_error($image)) { | |
$size = $image->get_size(); | |
$current_width = $size['width']; | |
$current_height = $size['height']; | |
// Determine the orientation of the image | |
$orientation = $current_width > $current_height ? 'landscape' : 'portrait'; |
WP_Query
is a powerful class in WordPress used to query posts. It allows developers to specify a variety of parameters to retrieve posts, pages, custom post types, and more.
- query: The query variables set in the new WP_Query instance.
- query_vars: An array of query variables.
- tax_query: The taxonomy query object.
- meta_query: The meta query object.
WP_Term
is a class in WordPress that represents terms within taxonomies such as categories, tags, or custom taxonomies.
- term_id: The ID of the term.
- name: The name of the term.
- slug: The slug of the term, used in URLs.
- term_group: The group that the term belongs to.
OlderNewer