Skip to content

Instantly share code, notes, and snippets.

@chaimaeML
chaimaeML / cpt.php
Created May 17, 2019 13:41 — forked from yratof/cpt.php
Wordpress AJAX search through custom post type
<form role="search" method="post" class="search-form padding-4" action="<?php echo home_url( '/' ); ?>">
<label>
<span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span>
<input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search...', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" />
<input class="post_type" type="hidden" name="post_type" value="frequent" />
</label>
<input type="submit" class="search-submit button brand" id="searchsubmit" value="<?php echo esc_attr_x( 'Search', 'submit button' ) ?>" />
</form>
<script type="text/javascript">
@chaimaeML
chaimaeML / even_odd_classes.php
Created April 29, 2019 10:48 — forked from gregrickaby/even_odd_classes.php
Even odd classes in WordPress loop
<?php
// WP_Query Arguments
$args = array(
'order' => 'DESC',
'posts_per_page' => 5
);
// The Loop
$query = new WP_Query( $args );
<?php if( have_rows('faqs') ): ?>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php $i=1; while ( have_rows('faqs') ) : the_row(); ?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-<?php echo $i; ?>">
<h2 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapse-<?php echo $i; ?>" aria-expanded="true" aria-controls="collapseOne">
<?php the_sub_field('question'); ?>
</a>
</h2>
@chaimaeML
chaimaeML / tabs
Created April 16, 2019 16:15
Advanced Custom Field repeater for Bootstrap Tabs
<!-- Check for parent repeater row -->
<?php if( have_rows('tab_panes') ): ?>
<ul class="nav nav-tabs" role="tablist">
<?php $row = 1; // number rows ?>
<?php // Step 1: Loop through rows, first displaying tab titles
while( have_rows('tab_panes') ): the_row();
// ?>
<li role="presentation" class="<?php if($row == 1) {echo 'active';}?>">
<a
href="#<?php echo $row; ?>"
@chaimaeML
chaimaeML / breadcrumbs-functions.php
Created February 5, 2019 15:33 — forked from tinotriste/breadcrumbs-functions.php
Wordpress: Breadcrumbs function
<?php
/*=============================================
= BREADCRUMBS =
=============================================*/
// to include in functions.php
function the_breadcrumb() {
$sep = ' > ';