Skip to content

Instantly share code, notes, and snippets.

@TarttWeb
TarttWeb / wordpress-action-example.php
Last active April 5, 2022 16:20
WordPress Action Example
<?php
function custom_copyright_notice() {
echo "Copyright © All Rights Reserved";
}
add_action('wp_footer','custom_copyright_notice');
@TarttWeb
TarttWeb / wordpress-filter-example.php
Last active April 5, 2022 16:18
WordPress Filter Example
<?php
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
@TarttWeb
TarttWeb / load-custom-script.php
Created April 5, 2022 16:14
WordPress Load Custom JavaScript File Example
<?php
function load_custom_script(){
wp_register_script( 'custom-js', custom.js', false );
wp_enqueue_script( 'custom-js' );
}
add_action( 'wp_enqueue_scripts', 'load_custom_script' );
@TarttWeb
TarttWeb / basic-html-doc-example.html
Last active April 5, 2022 17:53
Basic HTML Document Example
<!doctype html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Page Heading</h1>
<p>My first paragragh</p>
</body>
</html>
@TarttWeb
TarttWeb / html-id-class-example.html
Last active April 5, 2022 17:51
HTML ID & CLASS Example
<!doctype>
<html>
<head>
<title>Example of Element id & class attributes</title>
<style>
#main-heading {
font-size: 35px;
color: blue;
}
.my-first-paragraph {
@TarttWeb
TarttWeb / header-css-example.css
Last active April 5, 2022 17:52
H1 Header CSS Example
h1{
color: #0000ff;
font-size: 18px;
}
@TarttWeb
TarttWeb / basic-html-header-example.html
Created April 5, 2022 17:38
Basic HTML Header Example
<!doctype html>
<html>
<title>Page Title</title>
<body>
<div id="article-header">
<h1 class="article-title">Article Title</h1>
</div>
</body>
</html>
@TarttWeb
TarttWeb / basic-css-header-example.css
Last active April 5, 2022 17:47
Basic CSS Header Example
/* This is for the id */
#article-header {
background-color: #0000ff;
width: 100%;
padding: 20px;
}
/* This is for the class */
.article-title {
font-color: #ffffff;
font-size: 18px;
@TarttWeb
TarttWeb / add-reusable-blocks-wp-admin.php
Created April 5, 2022 18:13
Add Reusable blocks menu item to WordPress Admin area
<?php
// Add Reusable blocks to WordPress Admin area
function add_reusable_blocks_admin_menu() {
add_menu_page( 'Reusable Blocks',
'Reusable Blocks',
'edit_posts',
'edit.php?post_type=wp_block',
'',
'dashicons-editor-table',
22
@TarttWeb
TarttWeb / add-gtag-wordpress-header
Last active December 1, 2022 18:29
Add GTAG to WordPress Header
// Add Google Analytics to <head>
function add_google_analytics_to_head() {
// Paste the whole google tracking tag (gtag.js) here.
}
add_action( 'wp_head', 'add_google_analytics_to_head' );