Skip to content

Instantly share code, notes, and snippets.

@mattclements
mattclements / function.php
Last active July 2, 2024 15:32
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@nathaningram
nathaningram / gist:035b4c6b25738c9805d14495b80ce907
Created January 23, 2018 16:13
Adding SVG Format to Allowed WordPress File Types
//Adding SVG Format to Allowed WordPress File Types
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'add_file_types_to_uploads');
@brickbones
brickbones / wordpress-page-temaplate.php
Created April 20, 2019 18:07
WordPress page template with API (javascript and php)
<?php /* Template Name: Awesome Page */
get_header();
?>
<div class="latest-posts"></div>
<script>