Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Genesis Framework Base Code
<?php
/**
* Post Title
*/
add_action('genesis_post_title', 'genesis_do_post_title');
function genesis_do_post_title() {
if ( is_singular() ) {
$title = sprintf( '<h1 class="entry-title">%s</h1>', apply_filters( 'genesis_post_title_text', get_the_title() ) );
}
else {
$title = sprintf( '<h2 class="entry-title"><a href="%s" title="%s" rel="bookmark">%s</a></h2>', get_permalink(), the_title_attribute('echo=0'), apply_filters( 'genesis_post_title_text', get_the_title() ) );
}
echo apply_filters('genesis_post_title_output', $title) . "\n";
}
<?php
// pour tous les shortcode voir ce lien:
// http://www.studiopress.com/tutorials/shortcode-reference
/**
* Add the post info (byline) under the title
* @since 0.2.3
* perso: pour enlever titre lancer 'remove_action('genesis_before_post_content', 'genesis_post_info');
*/
add_filter('genesis_post_info', 'do_shortcode', 20);
add_action('genesis_before_post_content', 'genesis_post_info');
function genesis_post_info() {
if ( is_page() )
return; // don't do post-info on pages
$post_info = '[post_date] ' . __('By', 'genesis') . ' [post_author_posts_link] [post_comments] [post_edit]';
printf( '<div class="post-info">%s</div>', apply_filters('genesis_post_info', $post_info) );
}
/**
* Add the post meta after the post content
* @since 0.2.3
* perso: pour enlever meta lancer 'remove_action('genesis_after_post_content', 'genesis_post_meta');
*/
add_filter('genesis_post_meta', 'do_shortcode', 20);
add_action('genesis_after_post_content', 'genesis_post_meta');
function genesis_post_meta() {
if ( is_page() )
return; // don't do post-meta on pages
$post_meta = '[post_categories] [post_tags]';
printf( '<div class="post-meta">%s</div>', apply_filters('genesis_post_meta', $post_meta) );
}
<?php
// dans l'ordre du post
add_action('genesis_before_post_title', 'genesis_do_post_format_image');
add_action('genesis_post_title', 'genesis_do_post_title');
add_action('genesis_post_content', 'genesis_do_post_image');
add_action('genesis_post_content', 'genesis_do_post_content');
add_action('genesis_loop_else', 'genesis_do_noposts');
add_action('genesis_before_post_content', 'genesis_post_info');
add_action('genesis_after_post_content', 'genesis_post_meta');
add_action('genesis_after_post', 'genesis_do_author_box_single');
add_action('genesis_after_endwhile', 'genesis_posts_nav');
<?php
/****
* VERSION 1
* À METTRE DANS LE FICHIER FUNCTION APRÈS require_once(TEMPLATEPATH.'/lib/init.php');
* la fonction 'template_redirect' permet de faire un conditionnel sur les add_action ou
* remove_acion
****/
// Remove the page title
add_action('template_redirect', 'child_remove_my_template_page_title');
function child_remove_my_template_page_title() {
if ( is_page_template('page_my-template.php') )
remove_action('genesis_post_title', 'genesis_do_post_title');
}
/***
* VERSION 2
* À METTRE DIRECTEMENT DANS LE TEMPLATE
***/
// Template Name: My Template
// Remove the page title
remove_action('genesis_post_title', 'genesis_do_post_title');
genesis();
/***
* REMARQUE: Il est aussi possible d'utiliser 'template_redirect' directement dans
* un modèle de page
***/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.