Skip to content

Instantly share code, notes, and snippets.

@texe
texe / functions.php
Last active August 2, 2023 12:52
WordPress - Redirect to home page after login/logout in WordPress
// redirect to home after login/logout
add_action('wp_logout','go_home');
function go_home(){
wp_redirect( home_url() );
exit();
}
add_action('wp_login','go_home_after_login');
function go_home_after_login(){
wp_redirect( home_url() );
@agrogeek
agrogeek / Disabled panels WP editor.txt
Created April 29, 2020 14:52
Deshabilitar paneles del editor de WP desde código
// remove excerpt panel
wp.data.dispatch( 'core/edit-post').removeEditorPanel( 'post-excerpt' );
Here is an (incomplete) list of panel IDs:
taxonomy-panel-category - Category panel.
taxonomy-panel-CUSTOM-TAXONOMY-NAME - Custom taxonomy panel. If your taxonomy is topic, then taxonomy-panel-topic works.
taxonomy-panel-post_tag - Tags panel
featured-image - Featured image panel.
post-link - Permalink panel.
page-attributes - Page attributes panel.
@morgyface
morgyface / acf_image_to_featured_image.php
Created April 8, 2020 19:54
WordPress | Set ACF image to be the WP feature image
@akroii
akroii / php
Last active August 19, 2020 22:56
functions.php
<?php
/**
* Remove junk from wordpress, to help wordpress be more wordpress
**/
remove_action( 'wp_head', 'wp_resource_hints', 2);
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
@mbparvezme
mbparvezme / webP-to-wp.php
Last active July 4, 2021 08:09
Upload WebP image files to Wordpress
// --- TESTED WITH WordPress 5.3.2
// --- ADD BELLOW CODE TO function.php
//** Enable upload for webp image files */
function webp_upload_mimes($existing_mimes) {
$existing_mimes['webp'] = 'image/webp';
return $existing_mimes;
}
//** Enable preview / thumbnail for webp image files */
@metelidrissi
metelidrissi / disable_gutenberg_in_wordpress.php
Created September 17, 2019 14:56
Deshabilitar Gutenberg en WordPress
// disable for posts
add_filter(‘use_block_editor_for_post’, ‘__return_false’, 10);
// disable for post types
add_filter(‘use_block_editor_for_post_type’, ‘__return_false’, 10);
@IronGhost63
IronGhost63 / block-image.js
Last active February 6, 2020 13:55
Gutenberg image block - default link destination
(function(wp) {
wp.hooks.addFilter(
"blocks.registerBlockType",
"my-plugin/modify-linkDestination-default",
function (settings, name) {
if (name === "core/image") {
settings.attributes.linkDestination.default = "media";
} else if ( name === "core/gallery" ) {
settings.attributes.linkTo.default = "media";
}
// Disable Gutenberg Completely
// disable for posts
add_filter('use_block_editor_for_post', '__return_false', 10);
// disable for post types
add_filter('use_block_editor_for_post_type', '__return_false', 10);
@fencermonir
fencermonir / set_featured_image.php
Created December 10, 2018 14:14
Set First Image of the content as a featured image