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
@MatRouault
MatRouault / Deregister CSS
Created May 12, 2015 11:39
Deregister CSS
//* Deregister CSS from Events Manager & Buddypress Docs Plugins
//* http://justintadlock.com/archives/2009/08/06/how-to-disable-scripts-and-styles
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
wp_deregister_style( 'events-manager' );
wp_deregister_style( 'bp-docs-css' );
}
@MatRouault
MatRouault / bbpress
Created May 12, 2015 11:41
BBPress with Genesis
//////* BBPRESS *//////
/** Developped locally CAUTION !!! DELETE THIS BEFORE PRODUCTION */
add_filter( 'bbp_verify_nonce_request_url', 'my_bbp_verify_nonce_request_url', 999, 1 );
function my_bbp_verify_nonce_request_url( $requested_url )
{
return 'http://localhost:8888' . $_SERVER['REQUEST_URI'];
}
/** Force full width layout on forums posts only*/
@MatRouault
MatRouault / Custom excerpt length
Last active August 29, 2015 14:21
Custom excerpt length
echo '<p>' . wp_trim_words( get_the_excerpt(), 25 ) . '</p>';
/**
* Grid Content
* Change the number of words in excerpt if in the grid loop
*/
function gst_grid_content() {
// First, we make sure we're in the grid loop.
if( ! apply_filters( 'is_genesis_grid_loop', false ) )
@MatRouault
MatRouault / Automatically display titles on Category and Tag Archives
Created May 14, 2015 08:15
Automatically display titles on Category and Tag Archives
/**
* Default Category Title
*
* @author Bill Erickson
* @url http://www.billerickson.net/default-category-and-tag-titles
*
* @param string $headline
* @param object $term
* @return string $headline
*/
@MatRouault
MatRouault / Buddydrive in a Page
Last active August 29, 2015 14:24
Buddydrive in a Page Template
<?php
/*
Template Name: Documents
*/
//* Remove Genesis Loop and Add Custom Loop Instead
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
add_action( 'genesis_entry_content', 'fcu_do_custom_loop' );
/**
@MatRouault
MatRouault / addlinktobpmenu.php
Last active February 3, 2020 20:18
Add Link to BP Menu (User or Group)
<?php
// Do not include the opening php tag if it is already included in your file.
//* http://buddydev.com/buddypress/add-extra-links-to-buddypress-user-profile-menu-buddypress-group-menu/
add_action( 'after_setup_theme', 'buddydev_register_menus' );
function buddydev_register_menus() {
register_nav_menu( 'bp-profile-extra-links', __( 'Extra profile links' ) );
register_nav_menu( 'bp-group-extra-links', __( 'Extra Group links' ) );
@MatRouault
MatRouault / beans-secondary-menu.php
Last active April 14, 2016 19:47
Create a secondary sticky menu in Beans Framework and add this below header
<?php
// Do not include the opening php tag if it is already included in your file.
/* This code snippet adds a secondary sticky navigation in a subheader in #BeansTheme Framework.
* You can paste this in your functions.php file or add it in a a child-theme customization plugin.
* Some refs :
* http://www.getbeans.io/
* http://getuikit.com/docs/subnav.html
* http://getuikit.com/docs/sticky.html
* http://www.getbeans.io/code-reference/functions/beans_primary_menu/
@MatRouault
MatRouault / jobs-cpt.php
Last active April 15, 2016 10:13
Add Jobs Custom Post Type with taxonomy. Custom Fields built with Beans Framework APi.
<?php
/*
Plugin Name: Jobs CPT
Plugin URI: http://yourwebsite.com/
Description: Add Jobs CPT with taxonomy. Custom fields built with Beans Framework.
Version: 1.0
Author: You.
Author URI: http://yoururl.com/
License: GPLv2
*/
<?php
$args = array(
'post_type' => array( 'post' ),
'post_status' => array( 'publish' ),
'posts_per_page' => 100, // don't use -1, pick something reasonable
'no_found_rows' => true, // useful when pagination is not needed.
'update_post_meta_cache' => false, // useful when post meta will not be utilized.
'update_post_term_cache' => false, // useful when taxonomy terms will not be utilized.
// 'fields' => 'ids' // only good if all you need is ids
@MatRouault
MatRouault / showexcerpt.php
Last active April 23, 2016 15:09
Beans - Show Excerpt or Troncate Content if we're NOT on a singular post/page
<?php
// Do not include the opening php tag if it is already included in your file.
//* Show Excerpt or Troncate Posts Content
add_filter( 'the_content', 'sps_troncate_post_content' );
function sps_troncate_post_content( $content ){
if ( !is_singular() )