Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Plugin Name: WordPress Simple Google Analytics Plugin
Description: Lägger till Google Analytics-kod i <head> eller <footer> genom WordPress-hook
* Version: 1.0
* Author: D. Andersson
* Author URI: https://dandersson.nu
*/
defined( 'ABSPATH' ) or exit;
@deeman
deeman / remove-genesis-seo-meta.php
Created July 5, 2020 14:11
Remove Genesis meta description when using another SEO plugin.
// kill genesis meta description when using another SEO plugin. also remove genesis SEO metas from posts.
remove_action( 'genesis_meta','genesis_seo_meta_description' );
remove_action( 'admin_menu', 'genesis_add_inpost_seo_box' );
@deeman
deeman / functions.php
Created May 6, 2020 17:58
Manually Add Google Analytics Code to WordPress in functions.php
<?php
add_action('wp_footer', 'add_googleanalytics');
function add_googleanalytics() { ?>
// Paste your Google Analytics code here
<?php }
?>
@deeman
deeman / functions.php
Last active February 8, 2020 16:02
Setup Google Analytics tracking via PHP-hook
//Add Google Analytics function
function google_analytics() {
include_once("analyticstracking.php");
}
//Add tracking action, set Google Analytics
add_action('wp_head', 'google_analytics');
@deeman
deeman / functions.php
Created June 3, 2019 10:37
Elementor - Disable external scripts
//# Removing external scripts in Elementor #//
// For Google Fonts:
add_filter( 'elementor/frontend/print_google_fonts', '__return_false' );
// For Font Awesome Icons:
// Also works on none Elementor-pages
add_action( 'wp_enqueue_scripts', function() { wp_dequeue_style( 'font-awesome' ); }, 50 );
// To remove the Font Awesome http request as well:
@deeman
deeman / robots.txt
Last active February 4, 2020 10:29
Custom WordpPress/WooCommerce Robots.txt
User-agent: *
Disallow: /wp-admin/
Disallow: /?s=
Disallow: /search/
Allow: /admin/admin-ajax.php
Disallow: /cgi-bin/
Disallow: /wp-content/cache/
Disallow: /trackback/
Disallow: */trackback/
@deeman
deeman / functions.php
Created December 19, 2019 12:23
Add Featured Image in WordPress RSS Feed
function featuredtoRSS($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'featuredtoRSS');
add_filter('the_content_feed', 'featuredtoRSS');
@deeman
deeman / functions.php
Last active December 8, 2019 17:50
Genesis Framework Full Width 404 Page
// 404 Full Width Page
add_action( 'get_header', 'custom_404_layout' );
function custom_404_layout() {
if ( ! is_404() ) {
return;
}
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
}
@deeman
deeman / functions.php
Created December 5, 2019 12:17
NoIndex WooCommerce 'Order by' archives - via PHP
// Woocommerce SEO — Noindex 'Order by' archives
// Prevent indexing "Order by"
add_action( 'wp_head', 'woo_prevent_indexing_orderby' );
if(!function_exists('woo_prevent_indexing_orderby')){
function woo_prevent_indexing_orderby () {
if (isset($_GET['orderby'])){
echo '<meta name="robots" content="noindex, nofollow">';
}
}
@deeman
deeman / functions.php
Created November 27, 2019 10:09
Genesis Framework: Customize Post Navigations
//CUSTOM POST NAVIGATIONS
//* Customize the next page link
add_filter ( 'genesis_next_link_text' , 'sp_next_page_link' );
function sp_next_page_link ( $text ) {
return '&#x000BB;';
}
//* Customize the previous page link
add_filter ( 'genesis_prev_link_text' , 'sp_previous_page_link' );
function sp_previous_page_link ( $text ) {
return '&#x000AB;';