Skip to content

Instantly share code, notes, and snippets.

@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 May 18, 2023 18:57
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,
@trey8611
trey8611 / append_acf_repeater_data.md
Last active November 2, 2022 09:18
WP All Import & ACF Add-On - How to append data to repeaters | pmxi_saved_post

Append ACF Repeater Data

It's not possible to append a row to an ACF repeater field without a custom code workaround that utilizes our API: http://www.wpallimport.com/documentation/developers/action-reference/.

The following is an example to show you how this can be done. You will almost certainly need to adjust the code snippet to make it work with your data/site.

  1. Create a new "Manual Record Matching" import that updates the post(s): http://www.wpallimport.com/documentation/recurring/manual-record-matching/

  2. Store the ACF data in your own dummy custom field: http://d.pr/i/3Si4ad.