Skip to content

Instantly share code, notes, and snippets.

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

LOOR Lab loorlab

💻
💥👩‍🚀👨‍🚀💥
View GitHub Profile
@loorlab
loorlab / list_ACF_groups_fields_CPT_WP_CLI.bash
Created May 16, 2025 23:49
Show all groups and fields associated with the CPT person (all in one) - WP CLI
wp eval '
$field_groups = acf_get_field_groups(["post_type" => "person"]);
foreach ($field_groups as $group) {
echo "Grupo: {$group["title"]} (key: {$group["key"]})\n";
$fields = acf_get_fields($group["key"]);
if ($fields) {
foreach ($fields as $field) {
echo " - {$field["label"]} ({$field["name"]}) tipo: {$field["type"]}\n";
}
@loorlab
loorlab / display_custom_fields_CPT_WP_CLI.bash
Created May 16, 2025 23:43
Display in console the custom fields used by the CPT person - WP CLI
wp eval '
$posts = get_posts([
"post_type" => "person",
"posts_per_page" => 500,
"fields" => "ids"
]);
$keys = [];
foreach ($posts as $id) {
@loorlab
loorlab / list_terms_taxonomy_WP_CLI.bash
Created May 16, 2025 23:16
List terms from the persons_categories taxonomy - WP CLI
wp term list persons_categories --format=table
wp term list persons_categories --format=csv > persons_categories.csv
wp term list persons_categories --format=json
@loorlab
loorlab / display_all_taxonomies_CPT_post_WP_CLI.bash
Created May 16, 2025 23:12
Displays all taxonomies associated with the post's CPT and what terms are assigned to them. - WP CLI
wp eval '
$post_id = 53972; // ID
$post_type = get_post_type($post_id);
$taxonomies = get_object_taxonomies($post_type);
foreach ($taxonomies as $tax) {
$terms = get_the_terms($post_id, $tax);
echo "Taxonomía: $tax\n";
if (!empty($terms)) {
foreach ($terms as $term) {
echo "- {$term->name} (ID: {$term->term_id})\n";
@loorlab
loorlab / taxonomies-CPT-WP_CLI.bash
Created May 16, 2025 23:07
View the taxonomies associated with a CPT (e.g., person) - WP CLI
wp eval 'print_r( get_object_taxonomies("person") );'
@loorlab
loorlab / count_total_number_records_by_comma_WIN.bash
Created May 16, 2025 21:47
Count the total number of records in a comma-separated file (no-index.txt) in WIN, Bash console
expr $(tr -cd ',' < no-index.txt | wc -c) + 1
@loorlab
loorlab / translate_checkout_WOO.php
Created February 25, 2025 03:39
Translate : WooCommerce Checkout Fields
<?php
// Force translate WooCommerce
add_filter('gettext', function($translated, $text, $domain) {
if ($domain === 'woocommerce') {
$translations = [
'Billing details' => 'Detalles de facturación',
'First name' => 'Nombre',
'Last name' => 'Apellido',
'Company name' => 'Nombre de la empresa',
'Country / Region' => 'País / Región',
@loorlab
loorlab / query_mysql_total_posts_exclude_pages_cpt_WP.sql
Created February 11, 2025 00:14
Query - MySQL - WordPress | Display all Posts exclude pages and other content type
SELECT
p.ID,
p.post_title,
p.post_status,
CONCAT(u.option_value, '/', p.post_name, '/') AS permalink
FROM
wp_posts p
JOIN
wp_options u
ON u.option_name = 'siteurl'
export default class EventEmitter
{
constructor()
{
this.callbacks = {}
this.callbacks.base = {}
}
on(_names, callback)
{
@loorlab
loorlab / query_mysql_total_posts_by_no_category_permalinks_WP.sql
Created January 20, 2025 08:35
Query - MySQL - WordPress | Total Posts by No Category and Permalinks