Skip to content

Instantly share code, notes, and snippets.

My son is my everything

Cameron Jones cameronjonesweb

My son is my everything
View GitHub Profile
cameronjonesweb / functions.php
Created May 10, 2017
[WordPress] Set the page title for a 404 page and prevent the_title filter affecting menu items
View functions.php
function 404_page_title( $title, $id ) {
if( is_404() && !get_post_type( $id ) ) {
$title = 'Page not found';
return $title;
cameronjonesweb / functions.php
Last active May 11, 2017 — forked from robincornett/functions.php
optional home.php--to show the posts (blog) page's title and content
View functions.php
add_action( 'edit_form_after_title', 'posts_page_edit_form' );
function posts_page_edit_form( $post ) {
$posts_page = get_option( 'page_for_posts' );
if ( $posts_page === $post->ID ) {
// Running this hook seems to remove the page for posts notice, it's a good idea to keep it
cameronjonesweb / wc-account-login.php
Last active Aug 3, 2018
Update WooCommerce sites to use the account page to login rather than wp-login.php
View wc-account-login.php
add_filter( 'login_url', 'cameronjonesweb_use_woocommerce_login_page' );
* If WooCommerce is active use the account page for logging in
* @param string $login_url The URL for login.
* @param string $redirect The URL to redirect back to upon successful login.
* @param bool $force_reauth
* @return string
cameronjonesweb / .htaccess
Last active May 30, 2017
Redirect all from domain
View .htaccess
RewriteEngine On
# Replace with the target domain
RewriteCond %{HTTP_HOST} !$ [NC]
# Any paths you wish to exclude for some reason
RewriteCond %{REQUEST_URI} !^/training
# Preserve the path
RewriteRule ^(.*)$$1 [L,R=301]
# All to the root
RewriteRule ^(.*)$ [L,R=301]
View .htaccess
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
cameronjonesweb / cameronjonesweb-button-generator.php
Last active Jul 12, 2017
PHP button generator for WordPress
View cameronjonesweb-button-generator.php
* Generates a button
* @param string $label The label of the button
* @param string $link The URL to link to
* @param array $classes Additional classes to add to the button element
* @param bool $new_window Whether to open in a new window or now
* @return string The HTML button element
View index.php
<!DOCTYPE html>
<?php wp_head(); ?>
<body <?php body_class(); ?>>
<?php var_dump( have_posts() ); ?>
<?php wp_footer(); ?>
cameronjonesweb / hosts
Last active Sep 3, 2018
Spotify ad block
View hosts
# Spotify ad block
View .htaccess
<FilesMatch ".pdf$">
Header set X-Robots-Tag "noindex"
cameronjonesweb / cameronjonesweb-fix-author-no-posts.php
Created Jul 10, 2017
Fixes an issue with WordPress where the current author is empty on author archives with no posts
View cameronjonesweb-fix-author-no-posts.php
add_action( 'template_redirect', 'cameronjonesweb_fix_author_no_posts' );
function cameronjonesweb_fix_author_no_posts() {
global $authordata;
if( is_author() && empty( $authordata ) ) {
You can’t perform that action at this time.