Skip to content

Instantly share code, notes, and snippets.

View MatRouault's full-sized avatar
🏠
Working from home

Mathieu MatRouault

🏠
Working from home
View GitHub Profile
@JiveDig
JiveDig / post_class_columns.php
Last active June 11, 2016 00:06
Use post_class (post class) to break post into columns Last example shows how to conditionally use post class, for specific templates or pages
/**
* Breaks the posts into 4 columns
* @link http://www.billerickson.net/code/grid-loop-using-post-class
*/
add_filter( 'post_class', 'tsm_archive_post_class' );
function tsm_archive_post_class( $classes ) {
global $wp_query;
// Keeps columns out of secondary loops ie: Genesis Featured Post widgets
if( ! $wp_query->is_main_query() ) {
return $classes;
@salcode
salcode / gist:7164690
Last active May 12, 2017 22:12
Genesis WordPress Framework adding custom classes to markup This gist was originally created as an example of what I perceived to be an inconsistent behavior, my error was failing to attach my code to action `genesis_setup`. Corrected version now appears below. 20131027 - merged Gary Jones's fork with corrections and refactoring
<?php
/*
* Examples to add custom classes to Genesis WordPress Framework Markup when using HTML5 output
*/
add_action( 'genesis_setup', 'srf_add_cust_classes', 15 ); // Priority 15 ensures it runs after Genesis itself has setup.
function srf_add_cust_classes() {
add_filter( 'genesis_attr_site-inner', 'srf_attr_site_inner' );
add_filter( 'genesis_attr_content-sidebar-wrap', 'srf_attr_content_sidebar_wrap' );
add_filter( 'genesis_attr_content', 'srf_attr_content' );
add_filter( 'genesis_attr_sidebar-primary', 'srf_attr_sidebar_primary' );
@mustardBees
mustardBees / functions.php
Last active August 11, 2021 14:40
Filter a few parameters into WordPress YouTube oEmbed requests. Enable modest branding which hides the YouTube logo. Remove the video title and uploader information. Prevent related videos from being shown once the video has played.
<?php
/**
* Filter a few parameters into YouTube oEmbed requests
*
* @link http://goo.gl/yl5D3
*/
function iweb_modest_youtube_player( $html, $url, $args ) {
return str_replace( '?feature=oembed', '?feature=oembed&modestbranding=1&showinfo=0&rel=0', $html );
}
add_filter( 'oembed_result', 'iweb_modest_youtube_player', 10, 3 );
@chrisegg
chrisegg / entry-background.php
Last active August 23, 2017 08:05
Add this code to your functions.php file. This code will add the backstretch functionality to your theme which handles the loading and sizing of the images.
<?php
//* Do NOT include the opening php tag
//* Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'cegg_load_scripts_styles' );
function cegg_load_scripts_styles() {
if ( is_singular( array( 'post', 'page' ) ) && has_post_thumbnail() ) {
wp_enqueue_script( 'cegg-backstretch', get_bloginfo( 'stylesheet_directory' ) . '/js/backstretch.js', array( 'jquery' ), '1.0.0', true );
/*
If you are using BP 2.1+, this will insert a Country selectbox.
Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup
Remove this function after the field is created.
*/
function bp_add_custom_country_list() {
if ( !xprofile_get_field_id_from_name('Country') && 'bp-profile-setup' == $_GET['page'] ) {
@imath
imath / bp-custom.php
Created August 14, 2014 13:18
This a snippet to auto join "just activated" members in one or more BuddyPress groups.
<?php
if ( ! class_exists( 'Imath_Auto_Join_Groups' ) ) :
/**
* AutoJoin new members to chosen groups
*
* This is a little snippet, feel free to :
* - use it
* - extend it..
@slaFFik
slaFFik / bp-xprofile-countries-list.php
Last active April 1, 2021 14:57 — forked from shanebp/BuddyPress xprofile add countries
BuddyPress xProfile - Add Countries
<?php
/**
* If you are using BP 2.1+, this will insert a Country selectbox.
* Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup
*/
function bp_add_custom_country_list() {
if ( !xprofile_get_field_id_from_name('Country') && 'bp-profile-setup' == $_GET['page'] ) {
@lmartins
lmartins / genesis_attr_add_class.php
Last active September 20, 2022 13:33 — forked from JiveDig/genesis_attr_add_class.php
Add classes and attributes to any element in Genesis
<?php
//* Add class to .site-container
add_filter('genesis_attr_site-container', 'jive_attributes_st_container');
function jive_attributes_st_container($attributes) {
$attributes['class'] .= ' st-container';
return $attributes;
}
//* Add class to .site-inner
@joshuadavidnelson
joshuadavidnelson / remove-post-type-from-search-results.php
Last active March 8, 2022 13:56
Remove a post type from search results, but keep all others
<?php
/**
* Modify query to remove a post type from search results, but keep all others
*
* @author Joshua David Nelson, josh@joshuadnelson.com
* @license http://www.gnu.org/licenses/gpl-2.0.html GPLv2+
*/
add_action( 'pre_get_posts', 'jdn_modify_query' );
function jdn_modify_query( $query ) {
@chlab
chlab / Smart_Sitewide_Notices_Widget.class.php
Last active August 29, 2015 14:14
Smarter BuddyPress sitewide notices widget that doesn't display the widget when there are no notices to show
<?php
/**
* Smarter version of the buddypress sitewide notices widget
*
* Fetches the notices in an output buffer and does not display widget when
* there is no content to display.
*
* Sadly this widget is necessary because buddypress only finds out if there
* are notices to be displayed while displaying them.
*