Skip to content

Instantly share code, notes, and snippets.

@beovulf
beovulf / social_button.php
Created February 5, 2016 14:52
Social button. Simple Share Button adder plugin
<button class="btn btn-default btn-bottom-page" data-toggle="modal" data-target="#modal1"><img src="<?php echo get_template_directory_uri(); ?>/img/share@2.png" alt="" / height="20" class="img-btn-bottom"> <?php _e('Share','taco'); ?></button>
<div class="modal fade bs-example-modal-lg" id="modal1" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-sm">
<div class="modal-content offer-form offer-form-modal">
<h4 class="social-text"><?php _e('Podziel się ze znajomymi', 'taco') ?>:</h4>
<?php echo do_shortcode("[ssba]"); ?>
</div>
</div>
@beovulf
beovulf / multiple_modal.html
Created February 5, 2016 14:25
multiple modal
<button class="btn btn-warning btn-offer btn-buy" data-toggle="modal" data-target="#modal1">Wykup udział</button>
<div class="modal fade bs-example-modal-lg" id="modal1" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg">
<div class="modal-content offer-form offer-form-modal">
<h3>Poproś o wycene:</h3><?php echo do_shortcode('[contact-form-7 id="375" title="Poproś o wycene"]'); ?>
</div>
</div>
</div>
@beovulf
beovulf / pagination_on_pages.php
Created February 5, 2016 13:16
Pagination on pages
<?php
$q = new WP_Query( array( 'post_type' => 'page', 'post_parent' => $page_ID, 'depth' => 1, 'posts_per_page' => 4, 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1) ) );
if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post();
?>
<?php endwhile;
if ( get_option('permalink_structure') ) {
$format = 'page/%#%';
} else {
$format = '&paged=%#%';
}
@beovulf
beovulf / slider_loop.php
Last active February 5, 2016 11:01
Slider loop
<?php
$page_ID = $post->ID;
$lightbox_id = 1; // important to set lightbox id outside the loop
$q = new WP_Query( array( 'post_type' => 'page', 'post_parent' => $page_ID, 'depth' => 1, 'posts_per_page' => -1 ) );
if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post();
$slider_array = array(get_field('slider_1') , get_field('slider_2') , get_field('slider_3') , get_field('slider_4'));
?>
@beovulf
beovulf / post_counter.php
Last active February 5, 2016 07:59
Post counter
/////////////// IN FUNCTION.PHP ///////////////
function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
@beovulf
beovulf / page_list.php
Last active February 4, 2016 09:20
List of child pages on page
$page_ID = $post->ID;
$args = array(
'child_of' => $page_ID,
// 'authors' => '',
// 'date_format' => '',
'depth' => 1
// 'echo' => '',
// 'exclude' => '',
// 'include' => '',
@beovulf
beovulf / wordpress_img.php
Last active February 3, 2016 09:32
Wordpress img
<img src="<?php echo get_template_directory_uri(); ?>/img/our_guests.jpg" alt="" class="img-responsive" />
@beovulf
beovulf / Absolute_centering.css
Created February 3, 2016 09:16
Absolute centering
.absolute-center {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
@beovulf
beovulf / Loop_direct_children.php
Created February 3, 2016 07:59
Loop direct children
<?php $q = new WP_Query( array( 'post_type' => 'page', 'post_parent' => 97, 'depth' => 1 ) );
if ( $q->have_posts() ) : while ( $q->have_posts() ) : $q->the_post();
?>
<?php endwhile; endif;?>
@beovulf
beovulf / excerpt_length.php
Created February 2, 2016 20:54
Excerpt length limit by word
function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');