Předávání parametrů v url

WordPress parametry v url automaticky "odstřihne". Je třeba přidat do functions.php:

function parameter_queryvars( $qvars ) {
    $qvars[] = 'yourvarname';
    return $qvars;
add_filter('query_vars', 'parameter_queryvars' );

a následně v šabloně použít:

global $wp_query;
if (isset($wp_query->query_vars['yourvarname'])) {
    print $wp_query->query_vars['yourvarname']; // něco udělej

Zdroj »


WP Staging - DB & File Duplicator & Migration

This duplicator plugin allows you to create an staging or development environment in seconds.

It creates a file clone of your website into a subfolder of your current WordPress installation with an entire copy of your database. This sounds pretty simple and yes it is! All the hard time consumptive database and file copy stuff including url replacements is done in the background.

Přidání nového příspěvku programátorsky

A function used to programmatically create a post in WordPress.
@returns -1 if the post was never created, -2 if a post with the same title exists, or the ID of the post if successful.

function programmatically_create_post($user_id) {
        // Initialize the page ID to -1. This indicates no action has been taken.
        $post_id = -1;

        // Setup the title of the post
        $title = 'My New Post'

        // If the page doesn't already exist, then create it
        if( null == get_page_by_title($title)) {
                // Set the post ID so that we know the post was created successfully
                $new_post = array(
                'post_title' => $title,
                'post_name' => my-new-post,
                'post_content' => 'Lorem ipsum dolor sit amet...',
                'post_status' => 'publish',
                'post_date' => date('j.n.Y H:i:s'),
                'post_author' => $user_id,
                'post_type' => 'post',
                'post_category' => array(0),
                'comment_status'  => 'closed',
                'ping_status'   => 'closed',
                $post_id = wp_insert_post($new_post);
        // Otherwise, we'll stop
        } else {
                // Arbitrarily use -2 to indicate that the page with the title already exists
                $post_id = -2;
        } // end if
} // end programmatically_create_post

Programmatically Create a Post in WordPress »
How to Create a Post in WordPress Programmatically » to Create a Post in WordPress Programmatically

To lze využít např. pro automatické vytvoření příspěvku z uživatelského profilu při jeho ukládání přes user_register hook:


Jak vytvořit a přidat vlastní shortcodes

Zakódování e-mailové adresy

function cwc_mail_shortcode( $atts , $content=null ) {
    for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';';
    return '<a href="mailto:'.$encodedmail.'">'.$encodedmail.'</a>';
add_shortcode('mailto', 'cwc_mail_shortcode');

Použití shortcode:


Obsah pouze pro přihlášené uživatele

function cwc_member_check_shortcode( $atts, $content = null ) {
         if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
                return $content;
        return '';

add_shortcode( 'member', 'cwc_member_check_shortcode' );

Použití shortcode:

[member]This text will be only displayed to registered users.[/member]

Zobrazení PDF v iframe

function cwc_viewpdf($attr, $url) {
    return '<iframe src="https://docs.google.com/viewer?url=' . $url . '&embedded=true" style="width:' .$attr['width']. '; height:' .$attr['height']. ';" frameborder="0">Your browser should support iFrame to view this PDF document</iframe>';
add_shortcode('embedpdf', 'cwc_viewpdf');

Použití shortcode

[embedpdf width="600px" height="500px"]http://infolab.stanford.edu/pub/papers/google.pdf[/embedpdf]

Volání shortcode v šabloně (mimo editor)

echo do_shortcode('[jmeno_shortcode]');

viz dokumentace.

Znepřístupnění shortcodes

There might be some cases that you need the shortcodes of the text to be omitted. When that time comes, strip_shortcodes() is your friend.

Let's say that you need to strip shortcodes in the homepage but let them run in other content pages:

function remove_shortcode_from_index( $content ) {
    if ( is_home() )
        $content = strip_shortcodes( $content );
    return $content;
add_filter( 'the_content', 'remove_shortcode_from_index' );

Jak vytvořit vlastní shortcode (musilda.cz) »
10 super useful WordPress shortcodes »
Mastering Wordpress shortcodes »
8 fun & useful shortcode functions for WordPress »

Používání uživatelských polí v šablonách

Using Custom Fields In Your WordPress Template »

// key = název (klíč) uživatelského pole
// $post->ID lze použít pouze v loopu
if($data = get_post_meta($post->ID, 'key', true)) {
    echo $data;

// v případě pole
if($data = get_post_meta($post->ID, 'key')) {
    echo $data[0];
    echo $data[1];

Detailed example for the usage of the add_post_meta, delete_post_meta, update_post_meta, and get_post_meta functions.

Poznámky administrátora ke kódu nebo pro zákazníka

Peter’s Post Notes for WordPress

This plugin adds a panel to the sidebar of the add and edit post / page screens so that users can add notes for themselves or others and keep track of these notes. Whenever you save a post, you can type a note to be displayed along with the post in the edit view.

When used with Peter's Collaboration E-mails 1.2 and up, the notes are sent along with the e-mails in the collaboration workflow. There is also a general and private notes system on the dashboard.

Možnost přidat poznámku ke každé stránce či příspěvku.

Simple Admin Notes

Adds a simple "Notes" section to the admin menu for taking down....notes Like a built in notepad, can leave notes for clients or yourself.

  • Uses WordPress's built in custom post types
  • Works like a regular post
  • Functions with default WYSIWYG editor
  • Shows all "Notes" on one page in tab format
  • Will not show in front end or search
  • Requires default post privileges

Plusem je WYSIWYG editor, tj. např. možnost odkazovat na komentované příspěvky, asi nejlepší.

WordPress Admin Notepad

Podobný jako předchozí, s jediným oknem pro poznámky. Možnost zapnout zobrazení poznámek na každé stránce. Lze konfigurovat ne/viditelnost a ne/editovatelnost pro 4 základní skupiny uživatelů.

Dashboard Notepad

This dashboard widget provides a simple notepad. The widget settings allow you to choose which roles can edit the notes, and which roles can merely read them.

You can display the contents of your notepad using a template tag and/or shortcode. The widget permissions apply to these tags as well: only users with permission to read the notes will see the notes on the front end. You can use div#dashboard-notes in your theme's CSS file to style the notes.

Dashboard Post-it

Adds a simple 'Post-it' widget to the Dashboard that allows you to leave yourself or other authors a note. The plugin can be configured and moved around as any other Dashboard widget. It will accept plain text or (sanitized) HTML. Only users with the capability "Edit dashboard" can edit the note.

Dashboard Site Notes

Add notes as admin notices in contextual help tabs, as well as compile them into an instruction manual or placed in a dashboard widget.

This is intended to build instructions into a site for clients, so it is focused on providing abilities only to the highest role of user available on a site, although it can be configured as a general purpose tool to leave temporary notes to any group on your site that has admin access.

WP Help

Site operators can create detailed, hierarchical documentation for the site's authors, editors, and contributors, viewable in the WordPress admin. Powered by Custom Post Types, you get all the power of WordPress to create, edit, and arrange your documentation. Perfect for customized client sites. Never send another "here's how to use your site" e-mail again!

You can now pull in help documents from another WP Help install, and they will be automatically updated when the source documents change (even additions and deletions!). Perfect for WordPress multisite installs, or consultants with a large number of client installs.

Testování šablony


The theme check plugin is an easy way to test your theme and make sure it's up to spec with the latest theme review standards. With it, you can run all the same automated testing tools on your theme that WordPress.org uses for theme submissions. The tests are run through a simple admin menu and all results are displayed at once. This is very handy for theme developers, or anybody looking to make sure that their theme supports the latest WordPress theme standards and practices.

Theme Unit Test »

The Theme Unit Test is an XML export of demo data that outlines most of the features built into WordPress, and while being mandatory for WordPress.org themes, it’s a good idea to quickly run through the tests when working with theme markets and client jobs. With this test you’ll know that your h6 tag is styled, that nested lists are supported, that images and videos won’t break your design layouts and so on. You won’t have requests like “I inserted a right-aligned image in the editor but it’s not right-aligned on the site”.

Essential Plugins for WordPress Theme Developers »

Vytvoření a úpravy šablony založené na Twenty Eleven

Vytvoření odvozené (child) šablony »

Změna stylopisu - barva, písmo, velikost nadpisů, popisky, komentářů, postranní lišty apod.

Více zde »

Digging Into Twenty Eleven »

Replace/Remove Default Header Image Twenty Eleven Theme »

Sidebar on Single Posts and Pages »

Adding a Narrow Sidebar on Each Side of TwentyEleven Single Post View »

Plugin pro různé změny layoutu a designu Twenty Eleven » Twenty Eleven Theme Extensions Plugin »

Plugin pro 3-sloupcové varianty Twenty Eleven »

Jak přidat logo do Twenty Eleven »

Logo a nadpis v Twenty Eleven »

How to Override Theme Functions »

  1. Copy (in full) the function you want to override from the parent theme.
  2. Paste it into functions.php in the root of your child theme’s folder. If functions.php doesn’t exist, create it.
  3. Rename the function from parent_theme_fun­ction to child_theme_fun­ction.
  4. Deactivate the parent function.
  5. Activate the child function.
// Removes thematic_blogtitle from the thematic_header phase
function remove_thematic_actions() {
// Call 'remove_thematic_actions' during WP initialization

// Add our custom function to the 'thematic_header' phase
add_action('thematic_header','fancy_theme_blogtitle', 3);