Skip to content

Instantly share code, notes, and snippets.

View justinwyllie's full-sized avatar

Justin Wyllie justinwyllie

View GitHub Profile
@petenelson
petenelson / wordpress-list-users.sql
Created May 3, 2016 18:00
WordPress: MySQL query to list user names, emails, and first & last name
SELECT wp_users.user_login, wp_users.user_email, firstmeta.meta_value as first_name, lastmeta.meta_value as last_name FROM wp_users left join wp_usermeta as firstmeta on wp_users.ID = firstmeta.user_id and firstmeta.meta_key = 'first_name' left join wp_usermeta as lastmeta on wp_users.ID = lastmeta.user_id and lastmeta.meta_key = 'last_name'
@eduwass
eduwass / duplicate-post.php
Last active September 17, 2024 15:16
Programmatically duplicating a WordPress post
<?php
/**
* Duplicates a post & its meta and returns the new duplicated Post ID.
*
* @param int $post_id The Post ID you want to clone.
* @return int The duplicated Post ID.
*/
function duplicate_post(int $post_id): int
{