Skip to content

Instantly share code, notes, and snippets.

Daniel Andersson deeman

Block or report user

Report or block deeman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@deeman
deeman / functions.php
Created May 6, 2020
Manually Add Google Analytics Code to WordPress in functions.php
View functions.php
<?php
add_action('wp_footer', 'add_googleanalytics');
function add_googleanalytics() { ?>
// Paste your Google Analytics code here
<?php }
?>
@deeman
deeman / functions.php
Created Dec 19, 2019
Add Featured Image in WordPress RSS Feed
View functions.php
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
Created Dec 5, 2019
NoIndex WooCommerce 'Order by' archives - via PHP
View functions.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 / robots.txt
Last active Feb 4, 2020
Custom WordpPress/WooCommerce Robots.txt
View 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 Nov 27, 2019
Genesis Framework: Customize Post Navigations
View functions.php
//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;';
@deeman
deeman / functions.php
Created Oct 5, 2019
Genesis Framework: Modify the Comments Submit Button Text
View functions.php
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Customize the submit button text in comments
add_filter( 'comment_form_defaults', 'sp_comment_submit_button' );
function sp_comment_submit_button( $defaults ) {
$defaults['label_submit'] = __( 'Submit', 'custom' );
return $defaults;
}
@deeman
deeman / functions.php
Created Oct 5, 2019
Genesis Framework: Modify the Comments Link Text
View functions.php
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Modify the comment link text in comments
add_filter( 'genesis_post_info', 'sp_post_info_filter' );
function sp_post_info_filter( $post_info ) {
return '[post_comments zero="Leave a Comment" one="1 Comment" more="% Comments"]';
}
@deeman
deeman / functions.php
Created Sep 29, 2019
WordPress: How to change default excerpt length
View functions.php
function new_excerpt_length($length) {
return 20;
}
add_filter('excerpt_length', 'new_excerpt_length');
@deeman
deeman / function-popular-post-template.php
Last active Sep 29, 2019
WordPress: Show most popular posts without a plugin
View function-popular-post-template.php
//Add this anywhere in your template where you wish to display the posts.
<?php
$popular_posts_args = array(
'posts_per_page' => 3,
'meta_key' => 'my_post_viewed',
'orderby' => 'meta_value_num',
'order'=> 'DESC'
);
@deeman
deeman / functions.php
Created Sep 23, 2019
WordPress - Remove Help-tab In Admin Area
View functions.php
// Remove 'help'-tab i Admin area
add_filter('contextual_help_list','contextual_help_list_remove');
function contextual_help_list_remove(){
global $current_screen;
$current_screen->remove_help_tabs();
}
You can’t perform that action at this time.