Skip to content

Instantly share code, notes, and snippets.

View gregoirenoyelle's full-sized avatar

Grégoire Noyelle gregoirenoyelle

View GitHub Profile
<?php
/*
Zone Auteur
---------------------------------------------------------------------------------------------------- */
/** Retirer la zone auteur sur les single */
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single' );
/** Afficher la zone auteur sur les singles */
add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );
@gregoirenoyelle
gregoirenoyelle / genesis-custom-post-type-hook.php
Last active October 19, 2015 07:21
Genesis Add Custom Post type
<?php
/** Supprimer les post info */
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
/** Suprimer les post meta */
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
@gregoirenoyelle
gregoirenoyelle / acf-genesis-flexible-structure.php
Last active February 20, 2017 09:23
ACF PRO Repeater et Flexible
<?php
// Template Name: Page avec Flexible
add_action( 'genesis_entry_content', 'gn_flexible_content', 50);
function gn_flexible_content() {
// Contrôle si le flexible a des champs
if( have_rows('flexible_content_field_name') ):
@gregoirenoyelle
gregoirenoyelle / wp-plugin-add-script-and-styles-woocom.php
Last active March 26, 2021 12:20
WordPress Extension de Thème
<?php
/*
Plugin Name: Options pour WooCommerce
Plugin URI: https://wwww.gregoirenoyelle.com
Description: Changer des réglage de WooCommerce depuis une extension.
Version: 2.0
Author: Grégoire Noyelle
Author URI: http://wwww.gregoirenoyelle.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
<?php // NE PAS METTRE CETTE BALISE
// A METTRE DANS VOTRE FICHIER functions.php
//* Ajouter le support de page pour les articles
add_post_type_support( 'post', 'page-attributes' );
//* Changer ordre d'affichage dans les pages d'archives des articles
add_action( 'pre_get_posts', 'gn_post_archive_order' );
function gn_post_archive_order( $query ) {
if ( $query->is_main_query() && !is_admin() && $query->is_category() || $query->is_tag() ) {
<?php
/**
* Register widget area. Twenty Fiften Theme
* In functions.php file
*
* @link https://codex.wordpress.org/Function_Reference/register_sidebar
*/
function twentyfifteen_widgets_init() {
register_sidebar( array(
'name' => __( 'Widget Area', 'twentyfifteen' ),
<?php
/***
* default set up for $in['toolbar1']
* bold,italic,strikethrough,bullist,numlist,blockquote,hr,alignleft,aligncenter,alignright,link,unlink,wp_more,spellchecker,wp_fullscreen,wp_adv
* default set up for $in['toolbar2']
* formatselect,underline,alignjustify,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help
* default set up for $in['block_formats']
* Paragraph=p;Address=address;Pre=pre;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5; Heading 6=h6
* @package TinyMCE
*/
@gregoirenoyelle
gregoirenoyelle / wp-acf-check.php
Last active December 28, 2020 15:43
ACF check
<?php
// A placer dans le fichier functions.php de votre thème
//* Contrôle si Advanced Custom Field est actif sur le site
if ( ! function_exists( 'get_field' ) ) {
// Variable pour URL de la page Extension
function page_plugin_redirect() {
return get_bloginfo('url') . '/wp-admin/plugins.php';
}
<?php
//* Single Portfolio
//* Enlever sidebar classique
remove_action( 'genesis_sidebar', 'genesis_do_sidebar');
add_action( 'genesis_sidebar', 'gn_sidebar');
function gn_sidebar() {
global $post;
//** check ACF
@gregoirenoyelle
gregoirenoyelle / wp-acf-image-genesis.php
Last active December 8, 2018 17:01
Add ACF image in your content
<?php
// Template Name: Image avant le contenu
//* Affichage du contenu ACF avant le contenu principal
add_action('genesis_entry_content','ap_contenu_fiche_cuisinier', 5);
function ap_contenu_fiche_cuisinier() {
//* Variables ACF pour l'image
// L'image ACF est enregistrée en tant que "ID de l'image"
$image_id = (int) get_field('nom_du_champ_image_acf');