Skip to content

Instantly share code, notes, and snippets.

RewriteEngine On
RewriteBase /
RewriteRule .* - [E=noabort:1]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
@freddielore
freddielore / scroll_to_id.js
Last active August 29, 2015 14:27
Scroll to specific ID. Must be added in the footer area.
<script type="text/javascript">
jQuery(document).ready(function($){
var scroll_delay = 4000;
var top = 230;
var app = {
init: function(){
var sel = window.location.hash;
// only autoscroll if ID is detected in the URL
@freddielore
freddielore / getQueryString.js
Last active February 5, 2018 15:03
Get query string from URL via Javascript #javascript
// e.g URL: https://google.com/?id=foo
// getQueryString('id') // retruns "foo"
getQueryString: function(field, url){
var href = url ? url : window.location.href;
var reg = new RegExp( '[?&]' + field + '=([^&#]*)', 'i' );
var string = reg.exec(href);
return string ? string[1] : null;
}
@freddielore
freddielore / smart_seo_import_size.php
Last active January 13, 2019 03:04
Smart SEO CSV Import Size
<?php
add_filter( 'smart_seo_import_size', 'my_custom_csv_import_limit', 9, 1 );
function my_custom_csv_import_limit($size){
// reducing it to 5 to avoid server timeouts
return 5;
}
?>
@freddielore
freddielore / smart_seo_export_size.php
Last active January 13, 2019 03:15
Smart SEO CSV Export Size
<?php
add_filter( 'smart_seo_export_size', 'my_custom_csv_export_limit', 9, 1 );
function my_custom_csv_export_limit($size){
// reducing it to 25 to avoid server timeouts
return 25;
}
?>
@freddielore
freddielore / smart_seo_export_fields.php
Created January 13, 2019 03:15
[Smart SEO Export Fields] Lets you export other custom fields to include in bulk editing
<?php
add_filter( 'smart_seo_export_fields', 'child_export_other_custom_fields', 8, 1 );
function child_export_other_custom_fields( $fields ){
$fields[] = '_custom_field_name'; // _custom_field_name will exported to CSV as well
$fields[] = '_another_custom_field'; // _another_custom_field will exported to CSV as well
return $fields;
}
?>
@freddielore
freddielore / functions.php
Last active June 5, 2019 02:37
[export-custom-fields] Exporting Custom Fields data for bulk editing #seo
<?php
add_filter( 'smart_seo_export_fields', 'my_theme_export_other_custom_fields', 8, 1 );
function my_theme_export_other_custom_fields( $fields ){
$fields[] = 'class_type'; // class_type will exported to CSV as well
$fields[] = 'fees'; // fees will exported to CSV as well
$fields[] = 'class_description'; // class_description will exported to CSV as well
return $fields;
}
add_action( 'smart_seo_import_update', 'my_theme_update_more_custom_fields', 10, 2 );
@freddielore
freddielore / functions.php
Created August 18, 2019 04:36
[smart_seo_export_title] smart_seo_export_title filter demo #wordpress #wp #seo
add_filter( 'smart_seo_export_title', 'demo_export_default_seo_titles', 8, 2 );
function demo_export_default_seo_titles( $title, $post ){
// if no custom SEO title being defined, get global defaults for Yoast
if( class_exists('WPSEO_Option' ) && empty($title) ){
$settings = get_option( 'wpseo_titles' );
$title = $settings['title-' . $post->post_type];
}
@freddielore
freddielore / functions.php
Last active August 18, 2019 04:52
[smart_seo_export_title_v2] smart_seo_export_title usage example #wordpress #genesis #seo
<?php
add_filter( 'smart_seo_export_title', 'demo_export_default_seo_titles_v2', 8, 2 );
function demo_export_default_seo_titles_v2( $title, $post ){
// if no custom SEO title being defined, get global defaults for Yoast
if( class_exists('WPSEO_Option' ) && empty($title) ){
$settings = get_option( 'wpseo_titles' );
$replacer = new WPSEO_Replace_Vars();
$title = $replacer->replace( $settings['title-' . $post->post_type], $post );
}
@freddielore
freddielore / smart_seo_export_fields.php
Created August 18, 2019 06:07
[smart_seo_export_fields] smart_seo_export_fields filter with added callback #wordpress #wp #seo #php
<?php
// add this to your theme's functions.php or ask your developer to append the following lines
add_filter( 'smart_seo_export_fields', 'demo_export_other_custom_fields', 8, 1 );
function demo_export_other_custom_fields( $fields ){
// See if this is a WPML site and add columns "language_code", "parent_title" to CSV
if( class_exists( 'SitePress' ) ){
$fields[] = array( 'language_code', 'callback_language_code' );
$fields[] = array( 'parent_title', 'callback_parent_lang' );
}