Skip to content

Instantly share code, notes, and snippets.

View dibakarjana's full-sized avatar
😀

Dibakar Jana dibakarjana

😀
View GitHub Profile
@dibakarjana
dibakarjana / functions.php
Created July 14, 2022 16:08
Wordpress - Redirect any page To Single Post Page or any other variable url
function redirect_to_single_post(){
global $wp_query;
if((is_archive() || is_category()) && $wp_query->post_count == 1){
// Setup post data
the_post();
// Get permalink
$post_url = get_permalink();
// Redirect to single post page
wp_redirect( $post_url );
}
@dibakarjana
dibakarjana / functions.php
Created March 2, 2020 15:41
remove_filter( 'the_content', 'wpautop' ); only for certain post types
//decide when you want to apply the auto paragraph
add_filter('the_content','my_custom_formatting');
function my_custom_formatting($content){
if(get_post_type()=='my_custom_post') //if it does not work, you may want to pass the current post object to get_post_type
return $content;//no autop
else
return wpautop($content);
}
@dibakarjana
dibakarjana / jquery-trigger.js
Created November 30, 2018 15:26
Hidden URL Download Button
$('.download_resume_trigger').each(function() {
$(this).on('click', function (event) {
event.preventDefault();
$(this).next()[0].click();
});
});
@dibakarjana
dibakarjana / page-properties.php
Last active March 6, 2018 14:51
Custom post type loop and taxonomy term as class
<?php
$new = new WP_Query('post_type=property');
while ($new->have_posts()) : $new->the_post(); ?>
<?php $terms = get_the_terms( $post->ID, 'location' ); ?>
<div class="element-item transition <?php foreach( $terms as $term ) echo ' ' . $term->slug; ?>" data-category="transition">
<div class="name"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
</div>
<?php endwhile; ?>
@dibakarjana
dibakarjana / functions.php
Created January 22, 2018 15:39
Wordpress: Send Email after any Post type status change
//https://codex.wordpress.org/Post_Status_Transitions
//send email to admin after user create new deal from frontend form.
add_action('future_to_pending', 'send_emails_on_new_event');
add_action('new_to_pending', 'send_emails_on_new_event');
add_action('draft_to_pending', 'send_emails_on_new_event');
add_action('auto-draft_to_pending', 'send_emails_on_new_event');
@dibakarjana
dibakarjana / index.html
Created August 12, 2013 20:53
A CodePen by Dibakar Jana. Percentage sized and still centered - Translate() has to be used instead of negative top margin, because that is based on width which doesn't work.
<div>
Percentage sized and still centered.
</div>
@dibakarjana
dibakarjana / index.html
Last active December 18, 2015 23:28
jQuery Variable Height
<html>
<head>
<meta charset="UTF-8">
<title>jQuery Variable Height</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
</head>
<body>
<div id="col1"></div>
<div id="col2"></div>
<div id="sidebar">asdsd <br>asdasd</div>