Instantly share code, notes, and snippets.

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>
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>
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>
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);
View related_posts_query_by_tag.php
View get_post_types_array.php
<?php
// Get post types
function skima_post_types() {
$post_types = get_post_types([], 'objects');
$posts = array();
foreach ($post_types as $post_type) {
$posts[$post_type->name] = $post_type->labels->singular_name;
}
return $posts;
}
View get_user_role.php
<?php
function prefix_user_role() {
$user_meta = get_userdata(get_the_author_meta( 'ID' ));
$user_roles = $user_meta->roles; //array of roles the user is part of.
echo !empty($user_roles[0]) ? $user_roles[0] : '';
}
View post_titles_array.php
<?php
// query for your post type
$products = new WP_Query(
array (
'post_type' => 'product',
'posts_per_page' => -1
)
);
// we need the array of posts
$posts_array = $products->posts;
View icon-class-to-icon-name-array.php
<?php
function chaoz_icon_array($k) {
$v = array();
foreach ($k as $kv) {
$kv = str_replace('-', ' ', $kv);
$kv = str_replace('icon', '', $kv);
$v[] = array_push($v, ucwords($kv));
}
foreach($v as $key => $value) if($key&1) unset($v[$key]);
return array_combine($k, $v);