Skip to content

Instantly share code, notes, and snippets.

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

Joy Chetry joychetry

🏠
Working from home
View GitHub Profile
@joychetry
joychetry / functions.php
Last active January 15, 2022 19:46
Insert Thumbnail Before First H2 and Insert Thumbnail After First Paragraph
<?php
//Insert Thumbnail After First Paragraph
add_filter( 'the_content', 'joy_insert_featured_image', 20 );
function insert_featured_image( $content ) {
$content = preg_replace( "/<\/p>/", "</p>" . get_the_post_thumbnail($post->ID, 'post-single'), $content, 1 );
return $content;
}
@joychetry
joychetry / popup-EleTemplate
Last active May 19, 2020 17:05
Remove 404 from Elementor Popups
A Fix for now:
Remove the link from the button, icon or text
Add an ID to the element you want to trigger your pop-up with
Go to Pop-up settings > Advanced > Open By Selector
Fill in your selector (with an ID add # in front of it)
This will remove the tag to the trigger, so scrapers won't see an invalid link anymore.
@joychetry
joychetry / footer.php
Created May 13, 2020 14:25
Open External Links on New Tab
@joychetry
joychetry / media-query.css
Created April 26, 2020 06:53 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@joychetry
joychetry / elementor.css
Last active April 26, 2020 05:33
Consistent Image Size
selector .elementor-image img {
border-radius: 10px 10px 10px 10px;
width: 400px;
height: 235px;
max-width: 100%;
object-fit: cover;
overflow: hidden;
}
@joychetry
joychetry / functions.php
Created April 20, 2020 10:08
Pull First Image as Featured Image if Featured Image is NA
/* START - Pull First Image as Featured Image if Featured Image is NA */
function crowwwn_auto_featured_image() {
global $post;
if (!has_post_thumbnail($post->ID)) {
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post->ID, $attachment_id);
}
@joychetry
joychetry / htmlwidget
Created April 12, 2020 20:12
Hide Sticky Header on Scroll Down / Show on Scroll Up Elementor
//Set Element ID to "stickycrowwwn"
<script>
document.addEventListener('DOMContentLoaded', function() {
jQuery(function($){
var mywindow = $(window);
var mypos = mywindow.scrollTop();
mywindow.scroll(function() {
if (mypos > 40) {
if(mywindow.scrollTop() > mypos) {
@joychetry
joychetry / elementor-css
Last active April 20, 2020 12:04
Responsive 100% Columns Alignment in Elementor
/* Quick Use */
/* Section */
selector .elementor-container .elementor-row {
flex-wrap: wrap;
}
/* Column */
selector {
width: 100%;
}
@joychetry
joychetry / functions.php
Last active April 5, 2020 19:09
Replace Default Post Excerpt to Yoast using Filter
add_filter( 'get_the_excerpt', 'replace_post_excerpt_crowwwn' );
function replace_post_excerpt_crowwwn($output)
{
$output=get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true);
if ($output == !NULL) {
return $output;
}
else {
$content = get_the_content();
return wp_trim_words( $content , '27' );
@joychetry
joychetry / functions.php
Created April 5, 2020 18:23
Enable SVG Upload in WP
function upload_svg_files( $allowed ) {
if ( !current_user_can( 'manage_options' ) )
return $allowed;
$allowed['svg'] = 'image/svg+xml';
return $allowed;
}
add_filter( 'upload_mimes', 'upload_svg_files');