Skip to content

Instantly share code, notes, and snippets.

@Kevinlearynet
Kevinlearynet / gutenberg-sample-blocks.html
Created April 10, 2025 13:16
Sample block content for the WordPress Gutenberg editor
<!-- wp:cover {"url":"https://picsum.photos/1024/430","id":2100,"dimRatio":50,"customOverlayColor":"#886049","isUserOverlayColor":false,"style":{"color":{"duotone":"var:preset|duotone|dark-grayscale"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-cover"><span aria-hidden="true" class="wp-block-cover__background has-background-dim" style="background-color:#886049"></span><img class="wp-block-cover__image-background wp-image-2100" alt="" src="https://picsum.photos/1024/430" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","fontSize":"large"} -->
<p class="has-text-align-center has-large-font-size">Cover / Hero</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:cover -->
<!-- wp:paragraph -->
<p>This is a paragraph block. Frankfurter beef esse do non turducken strip steak sint in pork chop commodo doner sirloin beef ribs. Qui doner boudin, turkey prosciutto beef ribs sed aliqua. Occaecat quis picanha, pork chop fatba
@wpmark
wpmark / render-post-terms-block-output.php
Created March 17, 2023 10:08
Modify the post terms block output in WordPress
<?php
/**
* Changes the links on post terms block for job listing category terms.
*
* @param string $block_content The block content.
* @param array $block The full block, including name and attributes.
* @param WP_Block $instance The block instance.
*
* @return string $block_content The block content.
*/
@thisbit
thisbit / gb_query_events.php
Last active February 26, 2023 00:23
Upcoming events with generateblocks
<?php
/**
* Event query with GenerateBlocks
* Show only events that are happening in future, and order them from sooner to later
* @link https://community.generateblocks.com/t/generateblocks-query-loop-args-slowing-pages-way-down/903/9
* @link https://community.generateblocks.com/t/use-gb-query-loop-for-related-post/688/2
*/
function gb_query_events( $query_args, $attributes ) {
@thisbit
thisbit / new-tabs.css
Last active February 16, 2023 07:20
New and improoved Tabs for GenerateBlocks
/* Buttons as TABS */
.site .triggers .gb-button {
color: var(--contrast-2);
background-color: var(--base-2);
}
.site .triggers .gb-button:hover,
.site .triggers .gb-button:focus,
.site .triggers .gb-button:target,
.site .triggers .gb-button[aria-selected="true"] {
@thisbit
thisbit / assets_enqueuer.php
Last active October 29, 2022 05:40
Single query multiple loop with php an js filtering feature, with layouts with generatepress
<?php /**
* Enqueue the assets for the filtering staff feature
*/
function apuri_staff_filtering_assets() {
if ( is_page( array( 'nastavnici', 'lecturers' ) ) ) :
wp_enqueue_style( 'apuri-staff-filtering-assets', 'your plugin root' . 'assets/filter_and_search.css', false, '3.0.0.', 'all' );
wp_enqueue_script( 'apuri-staff-filtering-assets', 'your plugin root' . 'assets/filtering_and_search.js', false, '3.0.0.', 'all' );
endif;
}
@rmorse
rmorse / add-custom-editor-colors.php
Last active January 7, 2024 02:58
Add custom colors to the WordPress editor via `add_theme_support`
<?php
/**
* Add custom colors to the WordPress editor via `add_theme_support`
*
* This takes the existing colours (if your theme or a plugin has set any)
* and combines them with a new set of colours defined in the function
*
* New colours should be visible in the various color pickers found in
* WordPress admin
*/
@mrwweb
mrwweb / readme.md
Last active September 27, 2024 22:29
The Events Calendar v2 Template Reset & Customizations - Now on Github
@tarecord
tarecord / get_primary_taxonomy_term.php
Last active October 7, 2023 18:16
Returns the primary term for the chosen taxonomy set by Yoast SEO or the first term selected.
<?php
/**
* Returns the primary term for the chosen taxonomy set by Yoast SEO
* or the first term selected.
*
* @link https://www.tannerrecord.com/how-to-get-yoasts-primary-category/
* @param integer $post The post id.
* @param string $taxonomy The taxonomy to query. Defaults to category.
* @return array The term with keys of 'title', 'slug', and 'url'.
*/
@skyshab
skyshab / example.php
Created May 29, 2019 15:13
Custom Block editor template for event with tickets
<?php
// Return a custom order of the default blocks on an event.
// to change the order of the blocks, arrange the lines the blocks are added to the array.
// To remove a block from being added by default, comment out the line for the block.
add_filter( 'tribe_events_editor_default_template', function( $template ){
// initiate our array
$template = array();
@mixin custom-foundation-typography($reset: true) {
@if ($reset) {
// Typography resets
div,
dl,
dt,
dd,
ul,
ol,
li,