Skip to content

Instantly share code, notes, and snippets.

@Farmatique
Farmatique / gist:19f5199efa91fce46393a111c4a8bfd3
Created November 20, 2018 12:08
Wordpress PHP split (wrap) elements in array into rows
<?php
$myposts = get_posts( $args ); //Array of posts
$index = 1;
$len = count($myposts);
foreach( $myposts as $post ): setup_postdata($post);
$post_id = $post->ID;
?>
<?php
if( $index%3 === 1): echo '<div class="row">'; //Open row for every 3-rd (change 3 to desired number in one row)
endif;
@Farmatique
Farmatique / gist:983e9a21393778052ca9fba66a73eb67
Created November 19, 2018 17:26
Wordpress: get post id by slug
if ( $post = get_page_by_path( 'your-slug', OBJECT, 'your-post-type' ) ){
$post_id = $post->ID;
}
@Farmatique
Farmatique / gist:6b7258f89e048b7cc26bc2d5ea51699a
Last active November 15, 2018 18:21
Contact form 7 custom upload button
// in contact form
<div class="btn upload-file-btn">
[file file-967 class:fileuploadfield filetypes:.pdf|.txt|.jpg|.png|.gif|doc|.docx|.mp4|.3gp|.avi|.mov]
<input type="button" class="uploadbrowse-btn" value="Upload your file*">
<!-- or use button instead -->
<!-- <button class="uploadbrowse-btn" value="Upload your file*">Upload your file*</button> -->
</div>
//css
@Farmatique
Farmatique / gist:83f6cffa69013e28f01e855be5d07c6a
Created November 9, 2018 15:39
Wordpress: custom post type loop
<?php
$args = array( 'post_type' => 'testimonials', 'posts_per_page' => 10 );
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
?>
<h2> <?php echo the_title(); ?></h2>
<div class="content">
<?php echo the_content(); ?>
@Farmatique
Farmatique / gist:96901f3d161b2f7028676d21bd9cb8ad
Created November 8, 2018 10:31
Custom scroll scrollbar look
::-webkit-scrollbar {
width: 10px;
}
/* Track */
::-webkit-scrollbar-track {
background: #f1f1f1;
}
/* Handle */
@Farmatique
Farmatique / gist:8b5180c5cab8de63b4427a29f287cb7d
Created October 16, 2018 09:52
Custom HTML video controls
<div id="video-container">
<!-- Video -->
<video id="video" width="640" height="365">
<source src="videos/mikethefrog.webm" type="video/webm">
<source src="videos/mikethefrog.ogv" type="video/ogv">
<source src="videos/mikethefrog.mp4" type="video/mp4">
<p>
Your browser doesn't support HTML5 video.
<a href="videos/mikethefrog.mp4">Download</a> the video instead.
</p>
@Farmatique
Farmatique / gist:c67f89dda25f029954d7374127cf161c
Created October 3, 2018 09:09
Reset and sync local repository with remote branch
git fetch origin && git reset --hard origin/master && git clean -f -d
@Farmatique
Farmatique / gist:8d0dd702a19750d69963022a9d956e62
Created September 24, 2018 15:59
Video attributes for iphone
playsinline
autoplay
$ git remote rm origin
$ git remote add origin [email protected]:aplikacjainfo/proj1.git
$ git config master.remote origin
$ git config master.merge refs/heads/master
@Farmatique
Farmatique / gist:c8a0c03e32814ce4abe7eb43efd0deac
Created September 7, 2018 10:29
Wrap first letter in a word
$('p').html(function(i, html){
return html.replace(/^[^a-zA-Z]*([a-zA-Z])/g, '<span class="first-letter">$1</span>');
})