Skip to content

Instantly share code, notes, and snippets.

View raazon's full-sized avatar
❤️
Eat - Sleep - Code

Razon Komar Pal raazon

❤️
Eat - Sleep - Code
View GitHub Profile
@raazon
raazon / custom-post-type-ajax-pagination.php
Last active April 7, 2023 10:41
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;
@raazon
raazon / custom-post-type-pagination.php
Last active March 4, 2021 17:44
Wordpress custom post type pagination
<?php
/*
* Custom Post Pagination
* @since 1.0.0
* return
*/
if (!function_exists('wpdocs_custom_posts_pagination')) :
function wpdocs_custom_posts_pagination($the_query=NULL, $paged=1){
global $wp_query;
@raazon
raazon / get-current-address.html
Last active July 1, 2019 06:39
Get my current address using javascript
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Get my current address using javascript</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
@raazon
raazon / get-current-page-url-with-query-string.php
Created July 1, 2019 11:22
Get current url including query string in wordpress
/**
* Get current page url with query string
* @since 1.0.0
* @return: full url of your current page with query string
* @use: echo get_current_page_url();
*/
if ( ! function_exists( 'get_current_page_url_with_query_string' ) ) {
function get_current_page_url_with_query_string() {
global $wp;
return add_query_arg( $_SERVER['QUERY_STRING'], '', home_url( $wp->request ) );
@raazon
raazon / remove-taxonomy-slug-from-urls.php
Created July 4, 2019 12:24
Remove taxonomy slugs from URL (categories, post tags and custom taxonomies)
<?php
//------------------------------------------------------------------------------
// Remove taxonomy slugs (categories, post tags and custom taxonomies) from URL
// Resource Link: https://rudrastyh.com/wordpress/remove-taxonomy-slug-from-urls.html
//------------------------------------------------------------------------------
add_filter('request', 'ic_change_term_request', 1, 1 );
function ic_change_term_request($query){
$tax_name = 'category'; // specify you taxonomy name here, it can be also 'category' or 'post_tag'
@raazon
raazon / .htaccess
Last active July 15, 2019 11:17
Increase limit of maximum file upload size. If .htaccess file method doesn't work for you then you may edit php.ini file, hope second one must work 😊
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /staging/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /staging/index.php [L]
</IfModule>
# END WordPress
@raazon
raazon / git-commits.md
Created August 3, 2019 07:12
Git Commits

Pull then push new directory to existing git repository

  1. git init
  2. git remote add origin GIT_SSH_URL e.g: [email protected]:example/example.git
  3. git pull --rebase origin master
  4. git add .
  5. git commit -m "New Commit"
  6. git push --set-upstream origin master
@raazon
raazon / index.html
Last active August 5, 2019 09:37
HTML input type=file, get the image before submitting the form jquery
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<title>How to upload preview image before upload through JavaScript</title>
</head>
@raazon
raazon / username-exists.php
Last active September 5, 2019 04:23
Do while loop if username exists in php
<?php
// custom function for test only. You don't need to use this function if you use it with wordpress.
// Wordpress have already this function: https://developer.wordpress.org/reference/functions/username_exists/
function username_exists($user_login){
$names = ['Razon', 'Razon-1', 'Razon-2', "Supu"];
if(in_array($user_login, $names)){
return $user_login;
}else{
return false;
}
@raazon
raazon / toggle-password-field.html
Created September 9, 2019 10:18
How to toggle password visibility with jQuery
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">