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
/* Use WP-CLI instead https://developer.wordpress.org/cli/commands/search-replace/ */ | |
SET @oldsite='http://oldsite.com'; | |
SET @newsite='http://newsite.com'; | |
UPDATE wp_options SET option_value = replace(option_value, @oldsite, @newsite) WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET post_content = replace(post_content, @oldsite, @newsite); | |
UPDATE wp_links SET link_url = replace(link_url, @oldsite, @newsite); | |
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldsite, @newsite); | |
/* only uncomment next line if you want all your current posts to post to RSS again as new */ |
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 | |
/* | |
* Display posts only from today and in the future: | |
* http://old.support.advancedcustomfields.com/discussion/6000/how-to-sort-posts-by-acf-date-and-display-only-future-posts | |
* by Pasnon | |
*/ | |
$date_args = array( | |
'post_type' => 'events', |
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 | |
$file = '/path/to/file.png'; | |
$filename = basename($file); | |
$upload_file = wp_upload_bits($filename, null, file_get_contents($file)); | |
if (!$upload_file['error']) { | |
$wp_filetype = wp_check_filetype($filename, null ); | |
$attachment = array( | |
'post_mime_type' => $wp_filetype['type'], | |
'post_parent' => $parent_post_id, |
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
span { | |
display: inline-block; | |
height: 100%; | |
vertical-align: middle; | |
} | |
img { | |
display: inline-block; | |
vertical-align: middle; | |
} |
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 | |
function my_wp_is_mobile() { | |
if ( | |
! empty($_SERVER['HTTP_USER_AGENT']) | |
// bail out, if iPad | |
&& false !== strpos($_SERVER['HTTP_USER_AGENT'], 'iPad') | |
) return false; | |
return wp_is_mobile(); | |
} // function my_wp_is_mobile |
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 | |
function slug_order_archive_by_field( $query ) { | |
//Only do if is main query fo a specific cpt's archive. | |
//@TODO set cpt's name | |
if ( $query->is_main_query() && is_post_type_archive( 'CPT_NAME' ) ) { | |
//@TODO Set the name of the field we are ordering by | |
$query->set( 'meta_key', 'FIELD_NAME' ); | |
//@TODO change order to DESC IF you want to go in reverse order | |
$query->set( 'order', 'ASC' ); | |
//@TODO uncomment next line IF you want to sort by an integer instead of alphabetically |
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
USE __DATABASE__; | |
SET @username = 'azizur'; | |
SET @password = MD5('password'); | |
SET @fullname = 'Azizur Rahman'; | |
SET @email = '[email protected]'; | |
SET @url = 'http://azizur.com/'; | |
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_status`, `display_name`) VALUES (@username, @password, @fullname, @email, @url, NOW(), '0', @fullname); |
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_filter( 'wp_nav_menu_items', 'add_logout_link', 10, 2); | |
/** | |
* Add a login link to the members navigation | |
*/ | |
function add_logout_link( $items, $args ) | |
{ | |
if($args->theme_location == 'site_navigation') |
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
/** | |
* Disable script concatenation. | |
* If WordPress's dashboard isn't loading styles from load-styles.php | |
* add this to wp-config.php to disable concatenation and load styles that | |
* don't have errors | |
*/ | |
define( 'CONCATENATE_SCRIPTS', false ); |
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
# Batch renaming/mv/cp/etc... using bash | |
# Step 1: to make a backup copy of all pdf files in a directory | |
for i in *.pdf ; do mv "$i" "${i}.backup" ; done | |
# Step 2: to copy one file over all of the original files in this directory | |
for i in *.pdf ; do cp "~/source.pdf" "${i}" ; done |