Skip to content

Instantly share code, notes, and snippets.

View ahmadthedev's full-sized avatar

Muhammad Ahmad ahmadthedev

View GitHub Profile
@ahmadthedev
ahmadthedev / archive-numbered-pagination.php
Created March 26, 2024 05:31
Numbered pagination on Archive page with style
<?php
if( have_posts() ):
while( have_posts() ) : the_post();
get_template_part( 'template-parts/content', get_post_format() );
endwhile;
the_posts_pagination(array(
'mid_size' => 2,
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
import pandas as pd
import requests, csv, time, lxml, cchardet, re
from bs4 import BeautifulSoup
import concurrent.futures
sitemap = '' # Sitemap URL
s = requests.session()
sm = s.get(sitemap)
sm_soup = BeautifulSoup(sm.text, 'lxml')
<?php
/**
* Lazy Load All Images
*
* To Exclude, simply add this attr to img html: loading="not_lazy"
*
* @param string $html Post thumbnail HTML
*
* @return string Filtered post image HTML.
*/
<div class="container">
<div class="owl-demo">
<div class="slide-progress"></div>
<div class="owl-carousel owl-theme">
<div class="item">
<img src="http://placehold.it/850x350" alt="slide">
</div>
<div class="item">
<img src="http://placehold.it/850x350" alt="slide">
</div>
<?php
// Code from (https://www.codegrepper.com/code-examples/php/frameworks/yii/slug+to+string+php)
function slugify($text, string $divider = '-') {
// replace non letter or digits by divider
$text = preg_replace('~[^\pL\d]+~u', $divider, $text);
// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
<header class="hdr_top"></header>
<style>
.hdr_top { position: fixed; top: 0; left: 0; right: 0; z-index: 2; transition: transform 0.4s; background-color: #000; }
.scroll-down .hdr_top { transform: translate3d(0, -100%, 0); }
.scroll-up .hdr_top { padding: 10px 0; }
</style>
<script>
// Sticky Header
<?php
if (!function_exists('get_post_ids_by_meta_key_and_value')) {
function get_post_ids_by_meta_key_and_value($key, $value) {
global $wpdb;
$meta = $wpdb->get_results("SELECT post_id FROM `".$wpdb->postmeta."` WHERE meta_key='".$wpdb->escape($key)."' AND meta_value='".$wpdb->escape($value)."'");
$post_ids = [];
foreach( $meta as $m ) {
// Guideline
// Parent div after body `.prnt_sti`
<div class="prnt_sti">
<div class="container">
<div class="sticky-form">
<div class="sticky-form-inner">
</div>
</div>
</div>
<?php
// Display County (Custom Taxonomy) in States (Custom Taxonomy) - Add New Taxonomy Admin Column
add_filter( 'manage_edit-states_columns', 'wpdocs_add_new_states_columns', 10 );
function wpdocs_add_new_states_columns( $columns ) {
$columns['county'] = __( 'County' );
return $columns;
}
add_action( 'manage_states_custom_column', 'wpdocs_show_states_meta_info_in_columns', 10, 3 );
function wpdocs_show_states_meta_info_in_columns( $string, $columns, $term_id ) {
function subMenuSlide() {
if( jQuery('#menu-mega-menu li').hasClass('menu-item-has-children') ) {
jQuery('.menu-item-has-children').append( "<svg viewBox='0 0 140 140' width='24' height='24' xmlns='http://www.w3.org/2000/svg'><g><path d='m121.3,34.6c-1.6-1.6-4.2-1.6-5.8,0l-51,51.1-51.1-51.1c-1.6-1.6-4.2-1.6-5.8,0-1.6,1.6-1.6,4.2 0,5.8l53.9,53.9c0.8,0.8 1.8,1.2 2.9,1.2 1,0 2.1-0.4 2.9-1.2l53.9-53.9c1.7-1.6 1.7-4.2 0.1-5.8z' fill='black'/></g></svg>" );
}
jQuery('li.menu-item-has-children > svg').click(function() {
$parent = jQuery(this).parent().closest('li.menu-item-has-children');
if( !$parent.hasClass('child-menu-open') ) {
$parent.addClass('child-menu-open');
} else {
$parent.removeClass('child-menu-open');