This file contains hidden or 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 echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) );?> |
This file contains hidden or 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('the_content', 'remove_br_tags'); | |
function remove_br_tags($content) { | |
return preg_replace('/<br(\s+)?\/?>/i', "\n", $content); | |
} |
This file contains hidden or 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 force_distraction_free_mode() { | |
global $pagenow; | |
if ( $pagenow == 'post-new.php' ) { | |
?> | |
<script type="text/javascript"> | |
jQuery(window).bind("load", function() { | |
fullscreen.on(); | |
}); | |
</script> |
This file contains hidden or 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
cd ~ | |
sudo yum update | |
sudo yum install java-1.7.0-openjdk.i686 -y | |
wget https://github.com/elasticsearch/elasticsearch/archive/v0.90.6.tar.gz -O elasticsearch.tar.gz | |
tar -xf elasticsearch.tar.gz | |
rm elasticsearch.tar.gz | |
mv elasticsearch-* elasticsearch | |
sudo mv elasticsearch /usr/local/share |
This file contains hidden or 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 | |
require( 'wp-load.php' ); | |
//set_time_limit(30000); // you can set time limit, but I prefer to use command line > php fix-duplicated-posts.php | |
$query = "SELECT id,post_name, Count(*) FROM wp_posts WHERE post_type = 'post' GROUP BY post_name HAVING Count(*) > 1"; | |
$duplicated_posts = $wpdb->get_results( $query ); | |
foreach ( $duplicated_posts as $result ) { | |
$prepost = get_post($result->id); | |
$prepost->post_name = ''; |
This file contains hidden or 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 echo urldecode(str_replace('%26%23215%3B','x', urlencode(get_the_title()))); ?> |
This file contains hidden or 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 | |
/** | |
* Change upload dir for video post type | |
* Media files that comes from video post type will be stored under | |
* wp-content/uploads/video/year/month/file-name.blah | |
* use "upload_dir" filter | |
* @param $args | |
* @return mixed | |
*/ | |
public function video_upload_directory( $args ) { |
This file contains hidden or 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 | |
/** | |
* @param $q | |
* display custom post type in main loop! | |
* You can use conditional tags (http://codex.wordpress.org/Conditional_Tags) for show only front-end | |
*/ | |
function add_post_type_to_query( $q ) { | |
if ( $q->is_main_query() && is_home() ) { | |
$q->query_vars['post_type'] = array( 'post', 'video' ); // add whatever you want to show |
This file contains hidden or 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 restricted_upload_size() { | |
if ( ! current_user_can( 'manage_options' ) ) { | |
return 2 * 1024 * 1024; // 2mb | |
} | |
return 500 * 1024 * 1024; | |
} | |
add_filter( 'upload_size_limit', 'restricted_upload_size' ); |