This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('wp_footer', 'add_googleanalytics'); | |
function add_googleanalytics() { ?> | |
// Paste your Google Analytics code here | |
<?php } | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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">'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 '»'; | |
} | |
//* Customize the previous page link | |
add_filter ( 'genesis_prev_link_text' , 'sp_previous_page_link' ); | |
function sp_previous_page_link ( $text ) { | |
return '«'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"]'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function new_excerpt_length($length) { | |
return 20; | |
} | |
add_filter('excerpt_length', 'new_excerpt_length'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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' | |
); | |