Skip to content

Instantly share code, notes, and snippets.

@janisdonis
janisdonis / new_gist_file
Created July 13, 2013 07:08
Wordpress Advanced custom fields gallery template use
<div class="gallery thumb_list">
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php
$images = get_field('bildes');
if( $images ): ?>
<?php foreach( $images as $image ): ?>
<div class="gal_thumb">
<a href="<?php echo $image['sizes']['large']; ?>" rel="prettyPhoto[gallery<?php echo $post_id;?>]"><img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['title']; ?>"/></a> </div>
<?php endforeach; ?>
@janisdonis
janisdonis / new_gist_file
Created July 13, 2013 07:10
Custom field if then else
<?php
if( get_field('tips') == 'Quick' ) { ?>
<?php } ?>
<?php
if( get_field('tips') == 'Classic' ) { ?>
<?php _e( 'От', 'injoy' ); ?>
<?php } ?>
@janisdonis
janisdonis / new_gist_file
Created July 13, 2013 07:11
Wordpress custom post type single template
// Template selection
function my_template_redirect()
{
global $wp;
if ($wp->query_vars["post_type"] == "produkti")
{
include(TEMPLATEPATH . "/products-open.php");
die();
}
}
@janisdonis
janisdonis / class.php
Created December 17, 2013 12:20
php class
function Affiliates_Contact() {
$this->__construct();
}
/**
* Creates a contact widget.
*/
function __construct() {
parent::__construct( false, $name = 'Affiliates Contact' );
add_action( 'wp_print_styles', array( 'Affiliates_Contact', '_print_styles' ) );
<script id="images2<?php echo get_the_ID(); ?>" type="text/cycle">[
<?php foreach( $images as $image ): ?>
<?php if ( $counter == 0 ) { ?>
<?php } else { ?>"<img src='<?php echo $image['sizes']['large']; ?>'>",<?php }
$counter++;
?>
<?php endforeach; ?>]
</script>
<div class="task task-1">
<a href="#" data-task="task-1-1" class="task-1-1"><span class="arrow"></span><span class="txt">Komunikācijas uzsākšana</span><span class="arrow"></span></a>
<a href="#" data-task="task-1-2" class="task-1-2"><span class="arrow"></span><span class="txt">Biznesa prasības</span><span class="arrow"></span></a>
<a href="#" data-task="task-1-3" class="task-1-3"><span class="arrow"></span><span class="txt">Līgums un projekta uzsākšana</span><span class="arrow"></span></a>
<a href="#" data-task="task-1-4" class="task-1-4"><span class="arrow"></span><span class="txt">Specifikācija</span><span class="arrow"></span></a>
<div class="clearfix"></div>
</div>
@janisdonis
janisdonis / short
Last active August 29, 2015 14:27
Wordpress multi taxonomy query with ACF repeater field
<?php
$args = array(
'post_type' => 'products',
'tax_query' => array(),
);
if(get_field('multi_filter') ) {
$temp = array();
while(has_sub_field('multi_filter')){
$_temp = array(
<?php
$args = array(
'post_type' => 'products',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'repa_products',
'field' => 'slug',
'terms' => 'excavators',
),
@janisdonis
janisdonis / gist:91c981bad140479091ed
Created September 8, 2015 15:09
Tax custom field
<?php
$args = array(
'post_type' => 'products',
'tax_query' => array(),
);
if(get_field('multi_filter') ) {
$temp = array();
while(has_sub_field('multi_filter')){
$_temp = array(
<?php
include 'config.php';
error_reporting (E_ALL ^ E_NOTICE);
$post = (!empty($_POST)) ? true : false;
if($post)
{