Skip to content

Instantly share code, notes, and snippets.

View Njengah's full-sized avatar
👨‍💻
Coding & Learning Everyday

Joe Njenga Njengah

👨‍💻
Coding & Learning Everyday
View GitHub Profile
@Njengah
Njengah / css-not-last-child.html
Created March 3, 2020 20:16
CSS select all except the last child as in this tutorial - https://njengah.com/css-not-last-child/
<html>
<head>
<title>CSS Not Last Child </title>
<style>
li {
list-style: none;
display: inline;
padding: 20px;
@Njengah
Njengah / display_category_in_wordpress.php
Created March 2, 2020 20:02
How to display category in WordPress as exaplined in this tutorial - https://njengah.com/display-category-name-in-wordpress/
<?php
/**
* Display Category in WordPress
*/
//Head hook to test the display
add_action('wp_head', 'test_category_name_display');
@Njengah
Njengah / wordpress_get_post_id_by_slug.php
Last active March 2, 2020 19:00
WordPress function to get post id by slug and test it with an action hook to wp_head for tutorial - https://njengah.com/get-post-id-by-slug-in-wordpress/
<?php
/**
* Function to get post ID By slug
*/
function get_id_by_slug($page_slug, $slug_page_type = 'page') {
$find_page = get_page_by_path($page_slug, OBJECT, $slug_page_type);
if ($find_page) {
return $find_page->ID;
@Njengah
Njengah / woocommerce_redirect_return_to_shop_to_previous_page.php
Created March 2, 2020 17:26
WooCommerce Redirect return to shop button to previous page
<?php
/**
* Redirect return to shop button to previous page
*
* @return $string
*/
add_filter( 'woocommerce_return_to_shop_redirect', 'njengah_return_to_shop_to_previous_page' );
@Njengah
Njengah / change_woocommerce_button_text_proceed_to_checkout.php
Created March 2, 2020 17:23
Change Proceed To Checkout Text in WooCommerce
<?php
/**
* Change Proceed To Checkout Text in WooCommerce
* Place this in your Functions.php file
**/
function woocommerce_button_proceed_to_checkout() {
$new_checkout_url = WC()->cart->get_checkout_url();
?>
@Njengah
Njengah / get_order_id_woocommerce.php
Created March 2, 2020 05:09
Code snippet to get order ID in WooCommerce
<?php
//Declare the global WooCoomerce Object & Post Object
global $woocommerce, $post;
//Assign the order ID using the $post->ID
$order = new WC_Order($post->ID);
@Njengah
Njengah / create_wordpress_login_form_shortcode.php
Created February 25, 2020 17:39
Create Custom WordPress login form without plugin [ WordPress Login form Shortcode ]
<?php
/**
* Code to Create Custom WordPress login form without plugin
* @author Joe Njenga
* @ gist -
*/
// Step 1: Create shortcode
function njengah_add_login_shortcode() {
@Njengah
Njengah / add-submenu-page_to_custom_post_type_example.php
Created January 22, 2020 17:06
Simple function to add submenu page to a custom post type menu in WordPress admin
<?php
// Hook
add_action('admin_menu', 'add_tutorial_cpt_submenu_example');
//Callback function
function add_tutorial_cpt_submenu_example(){
<?php
//Njengah Tutorial Custom Post Type Example
//Hook
add_action('init', "njengah_tutorial_cpt");
//Callback function
@Njengah
Njengah / get_all_registered_sidebars_in_wordpress_theme.php
Last active January 19, 2020 21:15
Simple hook to get all registered sidebars in WorPress and display on the admin side
/**
* Simple hook to get all registered sidebars in WorPress and display on the admin side
*/
function get_all_registered_sidebars_in_wordpress(){
//global sidebars object
global $wp_registered_sidebars;