Skip to content

Instantly share code, notes, and snippets.

View loorlab's full-sized avatar
💻
💥👩‍🚀👨‍🚀💥

LOOR Lab loorlab

💻
💥👩‍🚀👨‍🚀💥
View GitHub Profile
@loorlab
loorlab / exclude_sitemap_yoast_seo_noindex_nofollow_id_file_WP.php
Created July 16, 2024 16:48
Exclude Sitemap YOAST + noindex - nofollow by ID no-index.txt - WP
<?php
/* YOAST SEO */
// FILE no-index.txt
function get_ids_from_file($file_path) {
if (file_exists($file_path)) {
$file_contents = file_get_contents($file_path);
$ids = explode(',', $file_contents);
@loorlab
loorlab / exclude_sitemap_yoast_seo_noindex_nofollow_id_WP.php
Created July 16, 2024 16:22
Exclude Sitemap YOAST + noindex - nofollow by ID - WP
<?php
/* YOAST SEO*/
add_filter('wpseo_exclude_from_sitemap_by_post_ids', 'exclude_persons_cpt_from_sitemap');
function exclude_persons_cpt_from_sitemap($excluded_posts) {
// ID para excluir del sitemap
$specific_posts_to_exclude = array(1147);
@loorlab
loorlab / wordpress_robots_custom.php
Created July 10, 2024 17:50 — forked from amboutwe/wordpress_robots_custom.php
Filters and example code for Yoast SEO robots or WP robots.txt
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/*
* Replace Disallow with Allow Generated Robots.txt
* Credit: Unknown
* Last Tested: June 09 2020 using WordPress 5.4.1
*/
add_filter('robots_txt','custom_robots');
@loorlab
loorlab / Search my gists.md
Created July 10, 2024 14:39 — forked from santisbon/Search my gists.md
How to search gists.

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

@loorlab
loorlab / master_query_sql_WP.sql
Last active July 2, 2024 00:48
Master Query - MySQL - WordPress
# ------------------------------------------------------------
# Master queries to modify databases in WordPress ------------
# ------------------------------------------------------------
# show all admin users
SELECT u.ID, u.user_login, u.user_email, u.user_nicename,
um.meta_value AS capability
FROM wp_users AS u
INNER JOIN wp_usermeta AS um ON (u.ID = um.user_id)
WHERE um.meta_key = 'wp_capabilities'
@loorlab
loorlab / query_change_table_prefix_SQL_WP.sql
Created May 9, 2024 17:49
Query WP - SQL - Change the table prefix for WordPress
update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_capabilities' where meta_key = 'OLDPREFIX_capabilities';
update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_user_level' where meta_key = 'OLDPREFIX_user_level';
update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_autosave_draft_ids' where meta_key = 'OLDPREFIX_autosave_draft_ids';
update NEWPREFIX_options set option_name = 'NEWPREFIX_user_roles' where option_name = 'OLDPREFIX_user_roles';
@loorlab
loorlab / enable_webp_WP.php
Last active February 7, 2024 19:59
Allow WebP Upload in WordPress
<?php
//enable upload for webp image files.
function webp_upload_mimes($existing_mimes) {
$existing_mimes['webp'] = 'image/webp';
return $existing_mimes;
}
add_filter('mime_types', 'webp_upload_mimes');
// functions.php
//enable preview / thumbnail for webp image files.
@loorlab
loorlab / rewrite_title_archives_WP.php
Last active October 12, 2023 21:31
Rewrite Title - To change the default output of get_the_archive_title() in WordPress, you can use the get_the_archive_title filter. This allows you to modify the title displayed for archive pages such as category, tag, date, and author archives.
<?php
// functions.php
function custom_archive_title($title) {
if (is_category()) {
$title = 'Category: ' . single_cat_title('', false);
} elseif (is_tag()) {
$title = 'Tag: ' . single_tag_title('', false);
} elseif (is_author()) {
$author = get_queried_object();
$title = 'Author: ' . $author->display_name;
@loorlab
loorlab / ACF_Relationship_WP.php
Created September 2, 2023 22:32
ACF Relationship - Shortcode
<?php
/* Recent Post | image */
function show_related_posts($atts) {
$atts = shortcode_atts(array(
'post_id' => get_option('page_on_front'),
), $atts);
$related_post_ids = get_field('recent_post', $atts['post_id']);
if ($related_post_ids) {
@loorlab
loorlab / minifier.php
Created August 7, 2023 02:44 — forked from abranhe/minifier.php
WordPress Minifier
<?php
/**
* W3C Fix and HTML minifier
* Nobody knows how this work, so don't touch it!!!
*
* https://wordpress.stackexchange.com/a/227896/129134
* https://stackoverflow.com/a/41148695
*/