Skip to content

Instantly share code, notes, and snippets.

View mdjwel's full-sized avatar
🎯
Focusing

Eh Jewel mdjwel

🎯
Focusing
View GitHub Profile
@mdjwel
mdjwel / ul_pagination.php
Last active July 21, 2022 17:52
Apply Custom ul>li Pagination in WordPress
<?php
function saasland_pagination() {
global $wp_query;
if ( $wp_query->max_num_pages <= 1 ) return;
$big = 999999999; // need an unlikely integer
$pages = paginate_links( array(
@mdjwel
mdjwel / popular_posts_query.php
Last active September 11, 2021 06:40
WordPress Custom Query Based Condition
<?php
if( class_exists( 'WooCommerce' ) ) {
// WooCommerce stylesheets
wp_deregister_style( 'woocommerce-layout' );
wp_deregister_style( 'woocommerce-smallscreen' );
wp_deregister_style( 'tinvwl' );
if( is_shop() || is_tax( 'product_cat') || is_singular( 'product') || is_tax( 'product_tag') || is_checkout() || is_cart() || is_account_page() ) {
wp_enqueue_style( 'woocommerce-general' );
} else {
@mdjwel
mdjwel / Elementor_button_styles.php
Last active October 26, 2019 10:10
Elementor widget development snippets
<?php
/// -------------------- Buttons ----------------------------
$this->start_controls_section(
'buttons_sec',
[
'label' => __( 'Buttons', 'saasland-core' ),
]
);
$repeater = new \Elementor\Repeater();
@mdjwel
mdjwel / get_id_by_page_template.php
Created July 24, 2019 09:48
Get the page id by page template
<?php
function filix_get_page_template_id( $template = 'page-job-apply-form.php' ) {
$pages = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => $template
));
foreach($pages as $page){
$page_id = $page->ID;
}
return $page_id;
@mdjwel
mdjwel / string_manipulations_wp.php
Created April 5, 2019 10:27
Here, I'm listing some functions that do string manipulation in WordPress.
<?php
/**
* Get a specific html tag from content
* @return a specific HTML tag from the loaded content
*/
function rogan_get_html_tag( $tag = 'blockquote', $content = '' ) {
$dom = new DOMDocument();
$dom->loadHTML($content);
$divs = $dom->getElementsByTagName( $tag );
$i = 0;
@mdjwel
mdjwel / cf7_forms_array.php
Last active February 5, 2019 08:00
Contact Form 7 Post Title Lists
<?php
if ( ! function_exists( '_get_contact_form_7_posts' ) ) :
function _get_contact_form_7_posts(){
$args = array( 'post_type' => 'wpcf7_contact_form', 'posts_per_page' => -1 );
$catlist = [];
if( $categories = get_posts( $args ) ){
@mdjwel
mdjwel / the_first_category_name.php
Last active January 27, 2019 19:47
Get the first category name and link in WordPress post's while loop.
<?php
// Get the 1ast category link
function Chaoz_first_category_link() {
$cats = get_the_terms(get_the_ID(), 'category');
$cat = is_array($cats) ? get_category_link($cats[0]->term_id) : '';
echo esc_url($cat);
}
// Get the first category link
function Chaoz_first_category_link() {
@mdjwel
mdjwel / banner_title.php
Created January 19, 2019 09:05
Display theme banner title based on what the page is
<?php
// Banner Title
function saasland_banner_title() {
$opt = get_option('saasland_opt');
if(is_home()) {
$blog_title = !empty($opt['blog_title']) ? $opt['blog_title'] : esc_html__('Blog', 'appland');
echo esc_html($blog_title);
}
elseif(is_page() || is_single()) {
the_title();
@mdjwel
mdjwel / walker_nave_menu_class_extend.php
Last active January 8, 2019 09:15
Walker_Nav_Menu class extending to match custom dropdown menu markup
<?php
/**
* WP Bootstrap Navwalker
*
* @package WP-Bootstrap-Navwalker
*/
/*
* Class Name: Gullu_Nav_Navwalker
*/