Skip to content

Instantly share code, notes, and snippets.

View hazratbilal0079's full-sized avatar
💭
I may be slow to respond.

Hazrat Bilal hazratbilal0079

💭
I may be slow to respond.
View GitHub Profile
@hazratbilal0079
hazratbilal0079 / WordPress Wpnonce Generation Shortcode and Handling in Bricks Builder
Last active June 6, 2024 08:46
WordPress Wpnonce Generation Shortcode and Handling in Bricks Builder
-- Shortcode
[wpnonce action='bricks-nonce-admin']
-- php Snippet or Code Snippet
// Function to generate the _wpnonce value
function generate_wpnonce_shortcode($atts) {
// Extract shortcode attributes, if any (default to 'bricks-nonce-admin' action)
@hazratbilal0079
hazratbilal0079 / Logout and Redirect to Specified Page Functionality for WordPress Logout Button without alert messages
Created June 6, 2024 08:41
Logout and Redirect to Specified Page Functionality for WordPress Logout Button without alert messages
-- Link on Button or Icon
https://yourwebsite.com/wp-login.php?action=logout
--Php Function or Code Snippet
add_action('check_admin_referer', 'logout_without_confirm', 10, 2);
function logout_without_confirm($action, $result)
{
@hazratbilal0079
hazratbilal0079 / Dynamic Data Tables with Column Visibility Toggle and Print Feature (Crocoblock)
Last active October 26, 2024 13:54
Dynamic Data Tables with Column Visibility Toggle and Print Feature (Crocoblock)
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/2.0.8/css/dataTables.dataTables.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/3.0.2/css/buttons.dataTables.css"/>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/2.0.8/js/dataTables.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/3.0.2/js/dataTables.buttons.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.dataTables.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.print.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/buttons/3.0.2/js/buttons.colVis.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/l
@hazratbilal0079
hazratbilal0079 / Retrieve Distinct meta field values from Custom Post Type in WordPress
Last active June 6, 2024 08:42
Retrieve Distinct meta field values from Custom Post Type in WordPress
SELECT DISTINCT pm.meta_value AS your_meta_field_name
FROM wpd8_posts AS p
INNER JOIN wpd8_postmeta AS pm ON p.ID = pm.post_id
WHERE p.post_type = 'your_post_type_name' AND pm.meta_key = 'your_meta_field_name';
Example
SELECT DISTINCT pm.meta_value AS property_name
FROM wpd8_posts AS p
INNER JOIN wpd8_postmeta AS pm ON p.ID = pm.post_id
@hazratbilal0079
hazratbilal0079 / Query to Check Duplicated in Custom Post Type based on the Meta Fields Only
Last active June 6, 2024 08:42
Query to Check Duplicated in Custom Post Type based on the Meta Fields Only
SELECT
p.ID AS post_id,
p.post_title,
pm1.meta_value AS property_name,
pm2.meta_value AS community_name,
pm3.meta_value AS type_owner_data,
pm4.meta_value AS area,
pm5.meta_value AS owner_number,
pm6.meta_value AS bedroom,
pm7.meta_value AS responsible_person,
@hazratbilal0079
hazratbilal0079 / Query to Check Duplicated Custom Post Types based on Terms and Meta Fields
Last active June 6, 2024 08:42
Query to Check Duplicated Custom Post Types based on Terms and Meta Fields
SELECT
p.ID AS post_id,
p.post_title,
p.post_author,
p.post_date,
tm1.name AS purpose,
tm2.name AS type_of_unit,
pm1.meta_value AS unit_number,
pm2.meta_value AS address_from_termlocation,
pm3.meta_value AS price,