Skip to content

Instantly share code, notes, and snippets.

View wisnust's full-sized avatar
🏠
Working from home

Wisnu Satrio T wisnust

🏠
Working from home
  • Indonesia
View GitHub Profile
@wisnust
wisnust / functions.php
Last active January 4, 2023 21:06
Estimated Reading time Wordpress without Plugin
<?php
function reading_time() {
$content = get_post_field( 'post_content', $post->ID );
$word_count = str_word_count( strip_tags( $content ) );
$reading_time_minutes = ceil($word_count / 200);
if ($reading_time_minutes == 1) {
$reading_time_label = 'minute';
} else {
@wisnust
wisnust / custom-post-type-ajax-pagination.php
Created February 16, 2021 18:50 — forked from raazon/custom-post-type-ajax-pagination.php
Wordpress custom post type ajax pagination
<?php
/*
* Custom Post Pagination
* @since 1.0.0
* return
*/
if (!function_exists('ic_custom_posts_pagination')) :
function ic_custom_posts_pagination($the_query=NULL, $paged=1){
global $wp_query;
@wisnust
wisnust / pagination.css
Created February 16, 2021 16:42 — forked from allenbell/pagination.css
Ajax pagination for posts linked via ACF Relationships - CSS
.bike-features {
margin-bottom: 15px;
}
#bike-features-container {
min-height: 400px;
}
#bike-features-inner, #bike-options-inner {
visibility: hidden;
@wisnust
wisnust / pagination.js
Created February 16, 2021 16:42 — forked from allenbell/pagination.js
Ajax pagination for posts linked via ACF Relationships - JavaScript
jQuery(document).ready(function($){
$(document).on( 'click touchstart', '#pagination a', function( event ) {
// Fade out the old content for a smooth transition
$('#bike-features-inner').fadeOut();
// The pagination button you clicked will pass the page number back to the callback function
var page = $(this).attr('href');
@wisnust
wisnust / pagination.php
Created February 16, 2021 16:41 — forked from allenbell/pagination.php
Ajax pagination for posts linked via ACF Relationships
<?php
function ajax_pagination_enqueue() {
// Register and enqueue our javascript file
wp_register_script( 'pagination',
get_template_directory_uri() . '/library/js/pagination.js', // or wherever you put the file in your theme directory
array('jquery'));
wp_enqueue_script('pagination');
<?php if( have_rows('collapse') ): ?>
<div id="accordion" role="tablist">
<?php $i=1; while ( have_rows('collapse') ) : the_row(); ?>
<div class="card">
<div class="card-header" role="tab" id="heading-<?php echo $i; ?>">
<h5 class="mb-0">
<a data-toggle="collapse" href="#collapse-<?php echo $i; ?>" aria-expanded="true" aria-controls="collapseOne">
<?php the_sub_field('title'); ?>
</a>
</h5>
<?php
/*
* WordPress Breadcrumbs
* author: Dimox
* version: 2019.03.03
* license: MIT
*/
function dimox_breadcrumbs() {
/* === OPTIONS === */
<?php if( have_rows('tabs') ): ?>
<ul class="nav nav-tabs" id="myTab" role="tablist">
<?php $i=0; while ( have_rows('tabs') ) : the_row(); ?>
<?php
$string = sanitize_title( get_sub_field('tab_title') );
?>
<li role="presentation" <?php if ($i==0) { ?>class="active"<?php } ?> >
<a href="#<?php echo $string ?>" aria-controls="<?php echo $string ?>" role="tab" data-toggle="tab"><?php the_sub_field('tab_title'); ?></a>
</li>
<?php $i++; endwhile; ?>