Skip to content

Instantly share code, notes, and snippets.

View pimedia's full-sized avatar
🏠
Working from home

Ali Qureshi pimedia

🏠
Working from home
View GitHub Profile
@pimedia
pimedia / functions.php
Created November 11, 2024 23:35
Display siblings of current WordPress page for Elementor Pro Query ID Custom Query in Posts widget
add_action( 'elementor/query/get_siblings', function( $query ) {
$current_pageID = get_queried_object_id();
// Modify the query
$query->set( 'post_parent', wp_get_post_parent_id($current_pageID) );
} );
@pimedia
pimedia / gist:75cbcee8d4dd470578ccbb5a8240c068
Created November 11, 2024 23:31
Display children of current WordPress page for Elementor Pro Query ID custom query in Posts widget
add_action( 'elementor/query/get_children', function( $query ) {
$current_pageID = get_queried_object_id();
// Modify the query
$query->set( 'post_parent', $current_pageID );
} );
@pimedia
pimedia / posts_by_category_query_id.php
Created October 24, 2024 20:56
Elementor Pro Query ID Custom Query Filter Snippet for WordPress Posts by Category Using Slug
add_action( 'elementor/query/posts_by_category', function( $query ) {
global $post;
$obj = get_category_by_slug($post->post_name);
$cat_id = $obj->term_id;
if($cat_id){
$taxonomy = 'category';
$tax_query = array(
array(
@pimedia
pimedia / gist:50ce5d05404df6744d519fe8cf362005
Created October 22, 2024 23:03
Add Custom Post Types CPT To WordPress Category & Tag Archives Pages Listing
function pim_cptui_add_post_types_to_archives( $query ) {
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$cptui_post_types = cptui_get_post_type_slugs();
$query->set(
@pimedia
pimedia / video-pause-resume.js
Created August 1, 2024 20:42
Pause / Resume Videos Using jQuery When Entering & Leaving Webpage Viewport on Scrolling
<script>
jQuery(document).ready(function() {
var $win = jQuery(window);
var elementTop, elementBottom, viewportTop, viewportBottom;
function isScrolledIntoView(elem) {
elementTop = jQuery(elem).offset().top;
elementBottom = elementTop + jQuery(elem).outerHeight();
@pimedia
pimedia / accordion_menu.php
Last active July 4, 2024 15:04
WordPress Accordion 3-Level Multilevel Menu. Use this shortcode with your menu name like this > [ pim_accordion_menu menu='Main' ].
<?php
function pim_get_menu_array($current_menu = 'Main Menu') {
$menu_array = wp_get_nav_menu_items($current_menu);
$menu = array();
function populate_children($menu_array, $menu_item) {
$children = array();
if (!empty($menu_array)) {
foreach ($menu_array as $k => $m) {
if ($m->menu_item_parent == $menu_item->ID) {
@pimedia
pimedia / select-drop-down-multimenu.php
Last active July 3, 2024 17:24
WordPress Select Drop Down 3 Level Menu. Use shortcode with menu name [pim_dropdown_menu menu='Main'].
<?php
function pim_get_dropdown_menu_array($current_menu='Main') {
$menu_array = wp_get_nav_menu_items($current_menu);
$menu = array();
function pim_populate_children($menu_array, $menu_item)
{
@pimedia
pimedia / acf_custom_fields.php
Last active June 26, 2024 21:19
Display ACF custom fields of event date, location google map on WordPress Post page before content using the_content hook
function pim_get_event_acf($content){
global $post;
$custom_fields = '';
if(is_singular('post')){
$location = str_replace(' ', '+', get_field('location'));
$start_date = str_replace('/', '-', get_field('event_date', $post->ID ));
$end_date = str_replace('/', '-', get_field('event_end_date', $post->ID ));
if($start_date) $start_date = date("F j, Y - h:i A", strtotime($start_date) );
if($start_date && $end_date) $end_date = date("F j, Y - h:i A", strtotime($end_date));
$website = get_field('website', $post->ID);
@pimedia
pimedia / styles.css
Last active June 23, 2024 15:09
Display a page list with thumbnails by taxonomy in WordPress. Use the shortcode anywhere in post, page or widget like this [taxonomy_pagelist tax='places-to-visit']
.wpb-page-list{
display: block;
margin: 10px 0 35px;
}
.wpb-page-list__item{
display: grid;
grid-template-columns: 60px 1fr;
grid-column-gap: 16px;
align-items: center;
text-decoration: none;
@pimedia
pimedia / script.js
Created January 31, 2022 18:21
This jQuery code is to verify the user credentials with ajax call from frontend for MemberClicks Auth Plugin.
jQuery("#login_form").submit(function(){
jQuery(".response_div").html('<div class="notice notice-info is-dismissible"><p class="spinner is-active">Checking user credentials..</p></div>');
var username = jQuery("input[name=user]").val();
var password =jQuery( "input[name=pass]").val();
jQuery.get(ajaxurl,{'action': 'test_user', 'username': username, 'password': password},