Skip to content

Instantly share code, notes, and snippets.

View sarathlal-old's full-sized avatar
🎯
Focusing

Sarathlal N sarathlal-old

🎯
Focusing
View GitHub Profile
https://www.dev4press.com/blog/tutorials/2017/url-rewriting-custom-post-types-date-archive/
Date archives are very useful if you want to list your posts only for the specified year, month or day. But, they only work with posts, and not with the custom post types.
Year archive: http://www.example.com/2011/
Month archive: http://www.example.com/2010/10/
Day archive: http://www.example.com/2012/02/22/
find . ! -name 'file.txt' -type f -exec rm -f {} +
will remove all regular files (recursively, including hidden ones) except file.txt. To remove directories, change -type f to -type d and add -r option to rm.
add_action( 'pre_get_posts', 'custom_post_type_archive' );
function custom_post_type_archive( $query ) {
if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'gallery' ) ) {
$query->set( 'posts_per_page', '12' );
$query->set( 'orderby', 'menu_order' );
$query->set( 'order', 'ASC' );
}
@sarathlal-old
sarathlal-old / template-htmltest.php
Created March 14, 2018 05:01
WordPress theme HTML testing template
<?php
/*
Template Name: HTML Test
*/
get_header();
?>
<h1>HTML tags with lorem ipsum...</h1>
<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>
file in server
<?php
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output("testsuccess.pdf",'F');
# Hide Yoast Meta boxes in unnecessary post type
function remove_yoast_metabox_reservations(){
remove_meta_box('wpseo_meta', 'your_post_type', 'normal');
}
add_action( 'add_meta_boxes', 'remove_yoast_metabox_reservations',100 );
<?php
/*
Plugin Name: Custom User Registration Notification
Description: Customized User registration notification
Version: 1.0
Author: Sarathlal N
Author URI: http://sarathlal.com
*/
// Redefine user notification function
add_filter('wp_mail_from', 'notification_from_email');
add_filter('wp_mail_from_name', 'notification_from_name');
function notification_from_email($email_address){
$blog_url = get_site_url();
$output1 = str_replace(array('http://','https://', 'www'), '', $blog_url);
$output2 = strstr($output1, '/', true);
if($email_address === "wordpress@" . $output2)
return 'noreply@'. $output2;
//Update malamutename
function malamutename_acf_load_field( $field ) {
$malamutename = htmlspecialchars($_GET["malamutename"]); //get URL query string - malamutename
$field['default_value'] = $malamutename;
return $field;
}
add_filter('acf/load_field/name=malamutename', 'malamutemame_acf_load_field'); //acf/load_field/name=yourfieldname
//Update sira
function sire_acf_load_field( $field ) {
function ghjut35_script() {
if(is_singular('product')){
?>
<script type="text/javascript">
function QueryStringToJSON() {
var pairs = location.search.slice(1).split('&');
var result = {};
pairs.forEach(function(pair) {
pair = pair.split('=');