Skip to content

Instantly share code, notes, and snippets.

@fritids
fritids / code
Created March 26, 2012 19:45
code wp
<?php add_action( 'init', 'change_author_permalinks' );
function change_author_permalinks()
{
global $wp_rewrite;
// On définit un nouveau tag pour les rôles des auteurs
add_rewrite_tag( '%author_level%', '([a-z0-9]+)' );
// On modifie la structure url de base des pages d'un auteur par notre nouveau tag
$wp_rewrite->author_base = '%author_level%';
// On met à jour les règles de ré-écriture
$wp_rewrite->flush_rules();
@fritids
fritids / gist:2209194
Created March 26, 2012 19:52
Modifier la structure url des profils auteurs en fonction de leur rôle
<?php
//http://www.geekpress.fr/wordpress/tutoriel/modifier-url-profils-auteurs-role-619/
add_action( 'init', 'change_author_permalinks' );
function change_author_permalinks()
{
global $wp_rewrite;
// On définit un nouveau tag pour les rôles des auteurs
add_rewrite_tag( '%author_level%', '([a-z0-9]+)' );
// On modifie la structure url de base des pages d'un auteur par notre nouveau tag
@fritids
fritids / gist:2209312
Created March 26, 2012 20:09
How to change author base without front
<?php
//http://wordpress.stackexchange.com/questions/31418/how-to-change-author-base-without-front
function change_author_permalinks() {
global $wp_rewrite;
$wp_rewrite->author_base = 'connect/member';
$wp_rewrite->author_structure = "/" . $wp_rewrite->author_base . '/%author%';
add_rewrite_rule('connect/member/([^/]+)/?$', 'index.php?author_name=$matches[1]', 'top');
}
add_action('init','change_author_permalinks');
@fritids
fritids / gist:2209319
Created March 26, 2012 20:11
Change WordPress Author Url Base
<?php
//http://w4dev.com/wp/change-wordpress-author-url-base/
function my_custom_author_base(){
$author_base = "profile" ; //Your desired author base.
global $wp_rewrite ;
$wp_rewrite->author_base = $author_base ;
$wp_rewrite->flush_rules() ;
}
@fritids
fritids / gist:2209326
Created March 26, 2012 20:12
wordpress-archive-page-with-all-authors-and-all-posts/
<?php
//http://www.scottbressler.com/blog/2011/03/wordpress-archive-page-with-all-authors-and-all-posts/
/**
* Template Name: All Author Archives
* Code: Scott Bressler (http://www.scottbressler.com/blog)
* Explanation: http://www.scottbressler.com/blog/2011/03/wordpress-archive-page-with-all-authors-and-all-posts
*/
get_header(); ?>
<div id="container">
<div id="content">
@fritids
fritids / gist:2231121
Created March 28, 2012 22:31 — forked from trepmal/gist:1566525
WordPress: Breadcrumb Functions
<?php
/*
Plugin Name: Breadcrumb Functions
Description: Functions for displaying breadcrumbs when working with hierarchical post types. Does nothing out-of-the-box, functions must be added to theme (directly or via hooks, your discretion).
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
*/
/*
Basic:
echo get_breadcrumbs( $post );
@fritids
fritids / gist:2231138
Created March 28, 2012 22:34 — forked from trepmal/gist:1520378
WordPress: [concept] Cross-CPT Parent/Child
<?php
//Plugin Name: [concept] Cross-CPT Parent/Child
//Description: Just a demo!.
add_action( 'init', 'kl_post_types');
function kl_post_types() {
register_post_type( 'parent', array(
'label' => 'Parent',
jQuery.fn.shake = function(intShakes, intDistance, intDuration) {
this.each(function() {
$(this).css({
position: "relative"
});
for (var x = 1; x <= intShakes; x++) {
$(this).animate({
left: (intDistance * -1)
}, (((intDuration / intShakes) / 4))).animate({
left: intDistance
<?php
/*
Template Name: All Authors' Page
Description: Get all the WordPress user's meta_information sort by the latest post action. (Which had at least 1 post published.)
*/
?>
<?php get_header(); ?>
<ul>
<?php
// offset -> post number | -1 means all the posts.
<?php
/* Mini Gavatar Cache */
/* 注:该程序中部分代码是WordPress所用,小幅修改即可复用。 */
function my_avatar( $email, $size = '50', $default = '', $alt = false ) {
$alt = (false === $alt) ? '' : esc_attr( $alt );
$f = md5( strtolower( $email ) );
$w = home_url(); //$w = get_bloginfo('url');
$a = $w. '/avatar/'. $f . '.jpg';
$e = preg_replace('/wordpress\//', '', ABSPATH) . 'avatar/' . $f . '.jpg';
$t = 604800; //设定7天, 单位:秒