Skip to content

Instantly share code, notes, and snippets.

View jerrickhakim's full-sized avatar

Jerrick Hakim jerrickhakim

View GitHub Profile
@jerrickhakim
jerrickhakim / My Domain to Affiliate Link Redirect with WordPress
Last active April 19, 2018 00:56
My Domain to Affiliate Link Redirect with WordPress
@jerrickhakim
jerrickhakim / HTML To Shortcode WordPress
Last active April 19, 2018 02:14
HTML To Shortcode WordPress
function register_my_shortcode() {
ob_start(); ?>
<div class="my-shortcode">
<h1>Hi, I am the shortcode.</h1><hr />
<p>This is a screenshot of how I was created!</p>
<img src="https://d153h1xtzgec02.cloudfront.net/shortcode-function-blog-post.png" alt="Function Screen Shot">
<p>I was created by pasting &#x5b;shortcode_name] on this post!</p>
</div>
<?php
return ob_get_clean();
@jerrickhakim
jerrickhakim / Register Plugin
Last active April 16, 2018 06:07
Starting a WordPress Plugin
<?php
/*
Plugin Name: Name
Plugin URI: http://url.com
Description: Create amazing pluigns
Version: 1.
Author: Jerrick Hakim
Author URI: http://jhakim.com
*/
@jerrickhakim
jerrickhakim / WordPress Login URL Redirect
Created March 21, 2018 18:10
WordPress Login URL Redirect
function jh_from_wp_login() {
$login_url = '/login';
wp_redirect( esc_url_raw( $login_url ) ); exit;
}
add_action( 'login_form_login', 'jh_from_wp_login' );
@jerrickhakim
jerrickhakim / Load Custom JS from Theme Folder
Created March 21, 2018 17:00
Enqueue Script & Styles Into WordPress Theme
// LOAD CUSTOM JS
function load_custom_js() {
wp_enqueue_script( 'custom', get_stylesheet_directory_uri() . '/js/custom.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'load_custom_js' );
// LOAD CUSTOM STYLES
add_action( 'wp_enqueue_scripts', 'enqueue_load_fa' );
function enqueue_load_fa() {
@jerrickhakim
jerrickhakim / .htaccess 301 Redirect
Created March 21, 2018 08:12
.htaccess 301 Redirect
Redirect 301 /landingurl https://newurl.com/
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( 'IDHERE' == event.detail.contactFormId ) {
location = 'http://yoururlhere.com';
}
}, false );
</script>
@jerrickhakim
jerrickhakim / 404 Redirect to Home URL
Created March 19, 2018 05:08
Setting 404 Page Redirects in Wordpress by Modifying the 404.php File.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit();
?>
@jerrickhakim
jerrickhakim / 404 Redirect to Custom URL
Created March 19, 2018 05:08
Setting 404 Page Redirects in Wordpress by Modifying the 404.php File.
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".home_url('/replaceme'));
exit();
?>
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://yoururlhere.com");
exit();
?>