Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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/[email protected]" 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 / print_button.js
Created February 5, 2016 21:45
print button
$('#print').click(function(){
window.print();
});
@beovulf
beovulf / get_day_of_week.js
Created February 7, 2016 08:33
Get day of week
function getDayOfWeek() {
var newDate = new Date();
newDate = newDate.getDay();
for(i=1;i<=6;i++) {
if(newDate == i) {
$('#day'+i).addClass('active-day').prepend('<p class="today"><b>TODAY</b></p>');
$('#day'+i).parent().css('background-color','#4A9D22');
} else if (newDate == 0 && i == 6) {
$('#day7').addClass('active-day').prepend('<p class="today"><b>TODAY</b></p>');
$('#day7').parent().css('background-color','#4A9D22');
@beovulf
beovulf / smooth scroll.js
Created February 9, 2016 11:07
smooth scroll with links to other pages offset
// Smooth Scroll
$(function() {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html, body').animate({
scrollTop: target.offset().top-100