Skip to content

Instantly share code, notes, and snippets.

View Jehu's full-sized avatar

Marco Michely Jehu

View GitHub Profile
@Jehu
Jehu / function.php
Last active September 13, 2023 14:10
WordPress: set category menu active on post single page
<?php
/**
* helper function to test if post is in subcategory
*/
if (!function_exists("mwe_is_in_subcategory")) {
function mwe_is_in_subcategory($categories, $_post = null)
{
foreach ((array) $categories as $category) {
$subcats = get_term_children((int) $category, "category");
@Jehu
Jehu / function.php
Created August 21, 2023 13:30
filter Bricks term query for custom taxonomy tag
<?php
// Include only terms where posts do have a term from custom 'hersteller' taxonomy
add_filter(
"bricks/terms/query_vars",
function ($query_vars, $settings, $element_id) {
if ($element_id !== "qaajzi") {
return $query_vars;
}
@Jehu
Jehu / function.php
Created August 9, 2023 08:36
Load ACSS in Gutenberg
<?php
// Load ACSS Gutenberg editor styles
function mwe_acss_gutenberg_styles() {
$url = site_url( '/wp-content/uploads/automatic-css/');
wp_enqueue_style( 'mwe-acss-gutenberg', $url . 'automatic-gutenberg-editor.css', false, '1.0', 'all' );
}
add_action( 'enqueue_block_editor_assets', 'mwe_acss_gutenberg_styles' );
@Jehu
Jehu / functions.php
Created December 13, 2022 12:22
SEOPress manual FAQ Schema + Metabox.io – Use related custom FAQ post type
/**
* FAQ Schema.org for MetaBox Relationship if manual FAQ Schema is active
*
* @See https://www.seopress.org/support/hooks/filter-manual-faq-schema/
*/
add_filter('seopress_pro_get_json_data_faq','sp_pro_schema_faq_json', 10, 2);
function sp_pro_schema_faq_json($json, $context)
{
$relationship_id = 'faq-page'; // Replace with your Relationship ID
@Jehu
Jehu / image_sizes.php
Created February 8, 2022 16:07
WordPress - Additional Image Sizes
<?php
add_theme_support( 'post-thumbnails' );
add_image_size( 'image-480', 480, 0 );
add_image_size( 'image-640', 640, 0 );
add_image_size( 'image-720', 720, 0 );
add_image_size( 'image-960', 960, 0 );
add_image_size( 'image-1168', 1168, 0 );
add_image_size( 'image-1440', 1440, 0 );
add_image_size( 'image-1920', 1920, 0 );
@Jehu
Jehu / splitmenu.php
Last active February 16, 2022 12:40
WordPress: Menu for Child pages (Split Menu)
<?php
function mwe_get_parent_title() {
$post = get_post();
return get_the_title($post->post_parent);
}
function mwe_get_sidebar_menu() {
$post = get_post();
if ( is_page($post->ID) && $post->post_parent ) {
$children = get_pages(array(
@Jehu
Jehu / shortcode_year.php
Created February 8, 2022 16:09
WordPress - Jahreszahl Shortcode
<?php
function year_shortcode () {
$year = date_i18n ('Y');
return $year;
}
add_shortcode ('year', 'year_shortcode');
@Jehu
Jehu / mySidebarPlugin.php
Created May 1, 2021 07:28
WordPress Custom Sidebar
<?php
/**
* Plugin Name: My Custom Sidebars
*/
/*
* Use this code for creating all sections you need, just add
* as many register_sidebar() functions as you need here.
*/
@Jehu
Jehu / functions.php
Last active February 28, 2020 07:41
Set hreflang="x-default" for WP Globus WordPress Plugin
<?php
/* ---------------------------------------------------------------------------
* Set hreflang="x-default" with WP Globus
* --------------------------------------------------------------------------- */
add_filter( 'wpglobus_hreflang_tag', 'custom_head_hreflang_xdefault', 10, 2 );
function custom_head_hreflang_xdefault() {
$hreflangs = WPGlobus_Utils::hreflangs();
$default_language = WPGlobus::Config()->default_language;
@Jehu
Jehu / plugin.php
Last active November 29, 2019 09:56
Use Groundhogg contact fields inside WPForms as smart tags
<?php
/**
* Plugin Name: WPForms GH Contact Smart Tag
* Plugin URI:
* Description: Use Groundhogg contact fields inside WPForms with Smart Tags. Se here for more informations about WPFOrms Smart Tags: https://wpforms.com/docs/how-to-use-smart-tags-in-wpforms/
* Version: 1.0
* Author: Marco Michely
* Author URI: https://www.michely-web-engineering.de
*/
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );