Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Plugin Name: My Custom Post Types
Description: Add post types for movies and movie reviews
Author: Liam Carberry
*/
// Hook <strong>lc_custom_post_movie()</strong> to the init action hook
add_action( 'init', 'lc_custom_post_movie' );
// The custom function MUST be hooked to the init action hook
add_action( 'init', 'lc_register_movie_post_type' );
// A custom function that calls register_post_type
function lc_register_movie_post_type() {
// Set various pieces of text, $labels is used inside the $args array
$labels = array(
'name' => _x( 'Movies', 'post type general name' ),
'singular_name' => _x( 'Movie', 'post type singular name' ),
<?php
/*
* Global Functions
*/
// Remove 'auto-paragraphing' from posts/pages
remove_filter( 'the_content', 'wpautop' );
/*
* Admin Control Panel Functions
// Variables
$my_name = "Liam Carbery";
// Functions
function display_my_name($name) {
echo $name;
}
// Clases
class Persons_Profile
// Associative array
$an_array = array(
"key" => "value",
"key2" => "value2"
);
// Standard Array
$another_array = array(
"one",
"two"
<?php $string = "My 'alt' tag"; ?>
<img src="https://www.codeproject.com/KB/GDI-plus/ImageProcessing2/img.jpg" alt="<?php esc_attr( $string ); ?>">
// Bad, messy
echo "Using \"quotation marks\" in a string can break out of the string";
// Good, more readable
echo 'Using "quotation marks" in a string can break out of the echo statement';
<p>
My <b>paragraph</b> of text which would probably introduce the list that's below.
</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'new-multisite-setup.dev');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);