Skip to content

Instantly share code, notes, and snippets.

@mdjwel
mdjwel / cf7_forms_array.php
Last active Feb 5, 2019
Contact Form 7 Post Title Lists
View cf7_forms_array.php
<?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 / button_styles.php
Last active Feb 5, 2019
Elementor widget development snippets
View button_styles.php
<?php
/// -------------------- Buttons ----------------------------
$this->start_controls_section(
'buttons_sec',
[
'label' => __( 'Buttons', 'saasland-core' ),
]
);
$repeater = new \Elementor\Repeater();
@mdjwel
mdjwel / banner_title.php
Created Jan 19, 2019
Display theme banner title based on what the page is
View banner_title.php
<?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 / custom_pagination.php
Created Dec 27, 2018
Apply Custom markup for Pagination in WordPress
View custom_pagination.php
<?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 / login_form.php
Created Dec 17, 2018
Custom user login form
View login_form.php
<form name="loginform" id="loginform" action="<?php echo esc_url(home_url('/')); ?>wp-login.php" method="post" class="sign_form">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12 form-group">
<input class="form-control" id="name_email" name="log" type="text"
placeholder="Username" onfocus="this.placeholder=''"
onblur="this.placeholder='Username'">
</div>
<div class="col-md-6 col-sm-6 col-xs-12 form-group">
<input class="form-control" type="password" name="pwd" id="pass"
placeholder="Password" onfocus="this.placeholder=''"
@mdjwel
mdjwel / walker_nave_menu_class_extend.php
Last active Jan 8, 2019
Walker_Nav_Menu class extending to match custom dropdown menu markup
View walker_nave_menu_class_extend.php
<?php
/**
* WP Bootstrap Navwalker
*
* @package WP-Bootstrap-Navwalker
*/
/*
* Class Name: Gullu_Nav_Navwalker
*/
View wp_next_prev_post_links.php
<?php
$prev_post = get_previous_post();
$next_post = get_next_post();
if($prev_post) : ?>
<a href="<?php echo get_permalink($prev_post->ID) ?>" class="prev"><i class="ti-arrow-left"></i>
<?php esc_html_e('Prev Project', 'saasland') ?>
</a>
<?php endif; ?>
<?php if($next_post) : ?>
<a href="<?php echo get_permalink($next_post->ID) ?>" class="next">Next Project<i class="ti-arrow-right"></i></a>
@mdjwel
mdjwel / striped_loop.php
Created Nov 13, 2018
bootstrap row loop, loop after a specific number of loops, striped loop
View striped_loop.php
<?php
if (!empty($settings['works'])) {
$i = 0;
foreach ( $settings['works'] as $work ) {
++$i;
?>
<div class="col-xs-12 col-sm-6 col-md-5 <?php echo ($i % 2 == 0) ? 'col-md-offset-2' : ''; ?>">
<div class="single-experience">
<div class="date"><?php echo esc_html($work['datetime']) ?></div>
<h4 class="title"><?php echo esc_html($work['title']) ?></h4>
@mdjwel
mdjwel / decimal_number_loop.php
Created Nov 12, 2018
Increase loop value by decimal point number
View decimal_number_loop.php
<?php
if (is_array( $faqs )) {
$i = 0.2;
foreach ( $faqs as $faq ) {
?>
<div class="col-xs-12 col-sm-6">
<div class="single-faq wow fadeInUp" data-wow-delay="<?php echo $i ?>s">
<h5 class="title"><?php echo esc_html($faq['title']) ?></h5>
<p> <?php echo wp_kses_post($faq['description']) ?> </p>
</div>
@mdjwel
mdjwel / custom_post_query_with_pagination.php
Created Sep 13, 2018
Show pagination in custom posts archive (loop) by custom post query $paged var
View custom_post_query_with_pagination.php
<?php
global $wp_query;
global $paged;
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts='.get_option('posts_per_page').'&post_type=t-shirts'.'&paged='.$paged);
You can’t perform that action at this time.