Skip to content

Instantly share code, notes, and snippets.

View developer-anuragsingh's full-sized avatar

Anurag Singh developer-anuragsingh

  • Cendyn
  • Gurugram
View GitHub Profile
/**
* Creates a new taxonomy for a custom post type
*
*/
public function register_new_CPT_Taxo() {
$cpt_name = 'Samhita';
$sanitized_cpt = sanitize_title($cpt_name);
$all_taxonomy = array('Veda');
foreach ($all_taxonomy as $single) {
/ Assign Category and Tags to WordPress Page
function add_taxonomies_to_pages() {
//register_taxonomy_for_object_type( 'post_tag', 'page' );
register_taxonomy_for_object_type( 'category', 'page' );
}
add_action( 'init', 'add_taxonomies_to_pages' );
/ Assign Category and Tags to WordPress Page
function add_taxonomies_to_pages() {
//register_taxonomy_for_object_type( 'post_tag', 'page' );
register_taxonomy_for_object_type( 'category', 'page' );
}
add_action( 'init', 'add_taxonomies_to_pages' );
Step 1 - Login to https://github.com/
Step 2 - Create a new repository https://github.com/new
Step 3 – optional – Add description
Step 4 – optional – select check box showing “Initialize this repository with a README””
Step 5 – optional – Select appropriate “gitignore”.
Step 6 – optional – Select appropriate “License”.
Step 7 – Click on “Create repository”
Step 8 – Click on link named as “clone or download” and copy the URL named as “Clone with HTTPS”
Step 9 – Go to https://desktop.github.com/
Step 10 – Download “github desktop” for window 7 or later
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
function remove_thumbnail_dimensions( $html ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
return $html;
}
// Ref - https://codex.wordpress.org/Plugin_API/Filter_Reference/ajax_query_attachments_args
add_filter( 'ajax_query_attachments_args', 'show_current_user_attachments', 10, 1 );
function show_current_user_attachments( $query = array() ) {
$user_id = get_current_user_id();
if( $user_id ) {
$query['author'] = $user_id;
}
return $query;
<?php
$taxoName = "dummy_taxo"; // Taxonomy Name
// Associative array of default arguments for Query
$args = array(
'taxonomy' => $taxoName, // Passed Taxonomy Name
'parent' => 0, // Get only top level terms
'hide_empty' => False // Get all the Terms
);
?>
<form action="" method="post">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hello User!</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".element span").text(function(index, text) {
return text.replace('old text', 'next text');
// Add same class in each li
jQuery(document).ready(function() {
jQuery('#menu-primary li a').each(function() {
jQuery(this).attr("class", "nav-link");
});
});
// Add class in each li
jQuery(document).ready(function() {
jQuery('#menu-primary li a').each(function(n){