Skip to content

Instantly share code, notes, and snippets.

View karks88's full-sized avatar

Eric Karkovack karks88

View GitHub Profile
@karks88
karks88 / register_post_meta_demo.php
Last active April 21, 2025 17:06
Block Bindings - Register Post Meta
// Register a Custom Field - Add to your theme's functions.php or a custom plugin.
function register_now_playing_meta() {
// Slug: now_playing
register_meta( 'post', 'now_playing', array(
'type' => 'string',
'single' => true,
'show_in_rest' => true, // Makes the field available to the Block Editor.
'sanitize_callback' => 'sanitize_text_field', // Sanitized for better security.
));
}
@karks88
karks88 / speckyboy-related-posts.php
Last active March 24, 2025 14:08
Related Posts Plugin Generated by AI - Version 1
@karks88
karks88 / block-styles.css
Last active September 11, 2024 16:21
Block Styles for the File List Block
/* Styles for the File List block */
ul.my-file-list-block {
margin: 2em 0;
}
ul.my-file-list-block li {
border-bottom: 1px solid #495D0F;
padding: 10px 0;
}
@karks88
karks88 / file-list.php
Last active September 11, 2024 16:15
File List Block Template
<?php
/**
* Block template file: /blocks/file-list/file-list.php
*
* File List Block Template.
*
* @param array $block The block settings and attributes.
* @param string $content The block inner HTML (empty).
* @param bool $is_preview True during AJAX preview.
* @param (int|string) $post_id The post ID this block is saved to.
@karks88
karks88 / block.json
Last active September 9, 2024 18:15
List Block's block.json
{
"name": "acf/file-list",
"title": "File List",
"description": "Display a list of documents for downloading.",
"style": [ "file:./block-styles.css" ],
"category": "formatting",
"icon": "media-document",
"keywords": ["document", "download", "list"],
"acf": {
"mode": "edit",
@karks88
karks88 / register-custom-blocks
Last active September 11, 2024 15:58
Register a Custom ACF Block
/* Register Custom Blocks */
function my_acf_custom_blocks_register() {
/**
* We register our block's with WordPress's handy
* register_block_type();
*
* @link https://developer.wordpress.org/reference/functions/register_block_type/
*/
register_block_type( __DIR__ . '/blocks/file-list' ); // File List Block
}
@karks88
karks88 / group_5cf655a17ba10.json
Last active September 9, 2024 14:16
File List Block Custom Fields
{
"key": "group_5cf655a17ba10",
"title": "File Listing",
"fields": [
{
"key": "field_5cf655b709906",
"label": "Custom File List",
"name": "",
"type": "message",
"instructions": "",
@karks88
karks88 / chatgpt-db-repsonse
Created June 20, 2024 12:50
ChatGPT explains a MySQL Query
To create a MySQL query that retrieves users with a WooCommerce Customer ID and a membership via Restrict Content Pro, you will need to join several tables: `wp_users`, `wp_usermeta`, `wp_wc_customer_lookup`, and `wp_rcp_memberships`.
Here is the query to achieve this:
```sql
SELECT
u.ID AS user_id,
um_first_name.meta_value AS first_name,
um_last_name.meta_value AS last_name,
wc.customer_id,
@karks88
karks88 / query
Created June 19, 2024 18:03
MySQL Query for: Use ChatGPT to Export Data from a WordPress Database
SELECT
u.ID AS user_id,
um_first_name.meta_value AS first_name,
um_last_name.meta_value AS last_name,
wc.customer_id,
rcp.status,
rcp.object_id
FROM
wp_users u
INNER JOIN
@karks88
karks88 / footer-contact-info.html
Last active January 22, 2023 13:58
A sample WordPress block template part