Skip to content

Instantly share code, notes, and snippets.

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

LOOR Lab loorlab

💻
💥👩‍🚀👨‍🚀💥
View GitHub Profile
@loorlab
loorlab / php_fatal_error_memory_WP_CLI.md
Last active November 14, 2024 00:45
PHP Fatal error: Allowed memory size of xx bytes exhausted (tried to allocate xx bytes) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Extractor.php on line 100 | WP CLI

Error

$ wp core download

[12-May-2022 06:07:40 UTC] PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 36864 bytes) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Extractor.php on line 100

Solution

$ php -d memory_limit=512M "$(which wp)" core download --locale=es_ES

@loorlab
loorlab / query_mysql_total_posts_by_category_WP.sql
Created November 8, 2024 15:15
Query - MySQL - WordPress | Total Posts by category
SELECT
COUNT(p.ID) AS total_contenidos
FROM
wp_posts p
JOIN
wp_term_relationships tr ON p.ID = tr.object_id
JOIN
wp_term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
JOIN
wp_terms t ON tt.term_id = t.term_id
@loorlab
loorlab / query_mysql_search_keyword_WP.sql
Last active November 8, 2024 15:13
Query - MySQL - WordPress | Search Keyword
SELECT
p.ID,
CONCAT(o.option_value, '/', p.post_name, '/') AS post_url
FROM
wp_posts p
JOIN
wp_options o ON o.option_name = 'siteurl'
WHERE
p.post_status = 'publish'
AND p.post_type = 'post'
@loorlab
loorlab / query_mysql_change_status_post_private_to_publish_WP.sql
Created October 14, 2024 01:21
Query - MySQL - WordPress | Change Status Private to Publish
UPDATE wp_posts
SET post_status = 'publish'
WHERE ID IN (
2804, 2808, 2812, 2816, 2821, 2823, 8676, 8677, 8678, 8701, 8702, 2829, 2831, 2833,
2836, 2838, 2840, 2842, 2844, 2846, 2848, 2850, 2852, 2854, 2856, 2858, 2860, 2862,
2864, 2868, 2959, 2961, 2963, 2965, 2968, 2970, 2972, 2974, 2976, 2978, 2980, 2982,
2985, 2987, 4368, 4370, 4375, 4377, 4379, 4381, 4383, 4389, 4393, 4395, 4397, 4399,
4401, 4403, 4405, 8564, 8566, 8567, 8565, 8568, 8569, 8570, 8571, 8572, 8573, 8883,
8884, 8885, 8886, 8887, 8888, 8951, 8952, 8953, 8954, 8956, 8957, 8958, 8959, 8960,
8961, 8955, 8962, 8963, 8964, 9094, 9095, 9096, 9097, 9098, 9099, 9100, 9101, 9102,
@loorlab
loorlab / query_mysql_display_post_revisions_WP.sql
Last active October 11, 2024 03:10
Query - MySQL - WordPress | Display Post Revisions
SELECT
p.ID AS original_post_id,
p.post_title AS original_post_title,
p.post_modified AS last_modified_date,
r.ID AS revision_id,
r.post_modified AS revision_date,
u.display_name AS author_name,
u.user_email AS author_email
FROM
wp_posts p
@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'