Trvalé odkazy v lokální instalaci XAMP

V lokální instalaci Apache obvykle defaultně nefunguje *mod_rewrite*, tj. obsah *.htaccess* je ignorován, a nastavíte-li si pak user-friendly odkazy např. pomocí /%postname%/, vrací se stránky/příspěvky jako nenalezené s kódem 404.

Napravit to lze změnou v souboru *httpd.conf*, který se nalézá v lokálním adresáři XAMPu *\apache\conf*.

Řádek

/—code php
#LoadModule rewrite_module modules/mod_rewrite.so
\—

stačí odkomentovat (vymazat znak *#*).

Dále je třeba zkonreolovat, zda v části

/—code php
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be „All“, „None“, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
\—

není zakomentována direktiva *AllowOverride All* (a je v tomto znění).

Po uložení *httpd.conf* a restartu lokálního Apache již WordPress odkazy přepisuje.

Problém s přesměrováním na jinou stránku

Potřebujeme-li v šabloně/pluginu/funkci přesměrovat výstup na jinou stránku, pomocí funkce „wp_redirect“:http://codex.wordpress.org/Function_Reference/wp_redirect nebo přímo přes „header(‚Location: http://www.example.com/‘)“:http://php.net/manual/en/function.header.php, může nastat problém, signalizovaný hláškou **Cannot modify header information – headers already sent by**.

Lze to vyřešit několika způsoby:

1) v php funkcí „ob_start“:http://php.net/manual/en/function.ob-start.php; zde „vysvětlení“:http://brian.moonspot.net/php-ob-start-headers

/—code php
// hned na začátek za úvodní umístíme
ob_end_flush();
?>
\—

2) javascriptem přes „window.location“:http://www.jakpsatweb.cz/javascript/objekt-window.html#location
/—code php



\—

3) pomocí „meta-refresh“:http://www.jakpsatweb.cz/presmerovani.html#meta
/—code php
„; ?>
\—

Související příspěvky

**Related Posts Slider**
„http://wordpress.org/extend/plugins/related-posts-slider/“:http://wordpress.org/extend/plugins/related-posts-slider/

Related posts slider creates a very attractive slider of the related posts or/and pages for a WordPress post or page.
The slider is a lightweight jQuery implementation of the related post functionality. It has a ready shortcode and widget as well to insert the slider.

– Showcase related posts in slider format, either in news style or in horizontal carousel format
– Complete CSS customization from settings panel
– Compatible with „YARPP plugin“:http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/ and „WordPress Related Posts plugin“:http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/
– Widget option available for Related Posts Slider
– Shortcode option to insert Related Posts Slider in between the content of a post
– Translation ready

[* http://s.wordpress.org/extend/plugins/related-posts-slider/screenshot-1.png?r=465251 *]

[* http://s.wordpress.org/extend/plugins/related-posts-slider/screenshot-2.png?r=465251 *]

*Alternativy*

Manuální nastavení souvisejících příspěvků

**Manual Related Posts**
„https://wordpress.org/plugins/baw-manual-related-posts/“:https://wordpress.org/plugins/baw-manual-related-posts/

You can manually choose which posts have to be be linked to every posts. Just click „Add related posts“, search for a post, click, add. Posts are linked to each others, example if you add on „Post A“ the „Post B“, then the „Post B“ will be linked to „Post A“ automatically, even if you can not see it in the backend.

„7 Awesome Related Post (Thumbnail) Plugins for WordPress »“:http://www.bloggenie.ca/best-related-post-plugins-thumbnails-wordpress/

Záložky („tabs“) na stránce nebo příspěvku

**WordPress Post Tabs**
„http://wordpress.org/extend/plugins/wordpress-post-tabs/“:http://wordpress.org/extend/plugins/wordpress-post-tabs/
„http://www.clickonf5.org/wordpress-post-tabs“:http://www.clickonf5.org/wordpress-post-tabs

Plugin for WordPress that will help you add as many tabs to your WordPress post or Page. So, say if you want to write some review, you can create various sections of the review post and display them in a tab view, i.e. separate tab for each section. This can be looked as a menu for your individual post, so that your readers can easily notice the distinct sections of your article or post or page.

You can choose from different styles, the looks of your post tabs or you can easily create your own style.

[* http://s.wordpress.org/extend/plugins/wordpress-post-tabs/screenshot-1.jpg?r=465089 *]

[* http://s.wordpress.org/extend/plugins/wordpress-post-tabs/screenshot-3.jpg?r=465089 *]

Odstranění automatického formátování

Automatické formátování, které wordpress provádí při úpravě v Editoru, i pod záložkou HTML je dvousečná zbraň. Při psaní článků hodně pomáhá, protože stačí udělat mezeru a hle, máme tu nový odstavec. Někdy ale automatický formátovač postihne amok a náš zamýšlený kód předělá k obrazu svému, který se vůbec neshoduje s původním plánem. […]

Menu s ikonami

A simple way to customize our WordPress menu, without losing its wonderful admin options. We will be doing:

– Home link in our wp_nav_menu that always gets current blog url
– Customize each menu item as you want
– Put pretty icons in our menu
– Active item highlight

„http://www.1stwebdesigner.com/wordpress/wordpress-wp-nav-menu-tutorial/“:http://www.1stwebdesigner.com/wordpress/wordpress-wp-nav-menu-tutorial/

[* http://www.1stwebdesigner.com/wp-content/uploads/2011/05/preview_large_wp_nav_tut.jpg *]

Frameworky a nástroje pro vytváření šablon

**PressWork**
„http://presswork.me/“:http://presswork.me/

The PressWork Toolbox lets you style any theme in a live preview environment without any code, drag & drop to set your layout in seconds, add Google fonts.

[* http://presswork.me/wp-content/themes/pw.me/images/pw_features.jpg *]

**WP Paintbrush**
„http://wppaintbrush.com/“:http://wppaintbrush.com/

Theme for WordPress, which comes with a built in editing panel, allowing anyone from beginners to advanced WordPress users to quickly create a unique and beautiful design for their website. WP Paintbrush makes it easy to redesign your site, even if you have zero knowledge of coding.

[* http://wppaintbrush.com/files/2011/06/layout-editor-500×361.png *]

Wonderflux
„http://wonderflux.com/“:http://wonderflux.com/

A powerful, free WordPress theme framework. It allows you to rapidly create unique WordPress themes – and the best part… it’s free (and always will be!) Wonderflux is open source GPLv2 licensed code – just like WordPress, so you can use it on unlimited client, personal and commercial websites with no subscription or cost.

WordPress Theme Generator
„http://www.yvoschaap.com/wpthemegen/“:http://www.yvoschaap.com/wpthemegen/

This online generator creates your own custom unique WordPress Theme. Without any need for HTML, JS, PHP, or CSS knowledge.
Change the colors, settings, layout, preview live, click „save“ and download your unique WordPress theme zip-file. Extract, upload, set, and you are done!

Praktické útržky kódu

**Title of the site**
/—code php

\—

**Basic URL of the site**
/—code php

\—
/—code php

\—

**Exact URL for the site (incl. path)**
/—code php

\—

**Name of the site**
/—code php

\—

**Site’s description**
/—code php

\—

**The style.css style’s location**
/—code php

\—

**The style.css style’s directory**
/—code php

\—

**Location for the site’s theme files**
/—code php

\—

**Title of the specific post or page**
/—code php


\—

**Url of a specific post or page**
/—code php

\—

**Category of a specific post or page**
/—code php

\—

**Author of a specific post or page**
/—code php

\—

**ID of a specific post or page**
/—code php

\—

**Link to edit a specific post or page**
/—code php

\—

**RSS2 URL for the site**
/—code php

\—

**Content of the posts**
/—code php

\—

**Header.php file’s content**
/—code php

\—

**Sidebar.php file’s content**
/—code php

\—

**Footer.php file’s content**
/—code php

\—

**The date in ’08-18-07′ format**
/—code php

\—

**Link for the comments on the post**
/—code php

\—

**Links from the blogroll**
/—code php

\—

**Comment.php file’s content**
/—code php

\—

**List of pages **
/—code php

\—

**List of categories**
/—code php

\—

**Url to the next post**
/—code php

\—

**Url to the previous post**
/—code php

\—

**The built-in calendar**
/—code php

\—

**List of archives for the site**
/—code php

\—

**Next and previous post link**
/—code php

\—

**Include any file**
/—code php

\—

**Value for search form**
/—code php

\—

**Prints out message**
/—code php

\—

**Displays the register link**
/—code php

\—

**Displays the login/logout link**
/—code php

\—

**Divides the content into pages**
/—code php

\—

**Cuts off the content and adds a link to the rest of the content**
/—code php
Pokračovat ve čtení „Praktické útržky kódu“

Práce s databází pomocí třídy $wpdb

**Načtení** ID a nadpisů čtyř nejnovějších příspěvků a jejich seřazení podle počtu komentářů (sestupně):

/—code php
get_results(„SELECT ID, post_title FROM $wpdb->posts WHERE post_status = ‚publish‘
AND post_type=’post‘ ORDER BY comment_count DESC LIMIT 0,4“)

// Echo the title of the first scheduled post
echo $posts[0]->post_title;
?>
\—

Objekt $results obsahuje pole s výsledky.

**get_row** načte pouze jediný záznam z tabulky:

/—code php
get_row(„SELECT ID, post_title FROM wp_posts WHERE post_status = ‚publish‘
AND post_type=’post‘ ORDER BY comment_count DESC LIMIT 0,1“)

// Echo the title of the most commented post
echo $posts->post_title;
?>
\—

**get_col** načte celý sloupec:

/—code php
get_col(„SELECT ID FROM wp_posts WHERE post_status = ‚publish‘
AND post_type=’post‘ ORDER BY comment_count DESC LIMIT 0,10“)

// Echo the ID of the 4th most commented post
echo $posts[3]->ID;
?>
\—

**get_var** načte jedinou hodnotu:

/—code php
get_var(„SELECT user_email FROM wp_users WHERE user_login = ‚danielpataki‘ „)

// Echo the user’s email address
echo $email;
?>
\—

**Vkládání do databáze**

/—code php
insert( $table, $data, $format);
$wpdb->insert($wpdb->usermeta, array(„user_id“ => 1, „meta_key“ => „awesome_factor“, „meta_value“ => 10), array(„%d“, %s“, „%d“));

// odpovídá:
// INSERT INTO wp_usermeta (user_id, meta_key, meta_value) VALUES (1, „awesome_factor“, 10);
?>
\—

**Updatování databáze:**

/—code php
// $wpdb->update($table, $data, $where, $format = null, $where_format = null);

// $where parameter – can be an array in the form of column-value pairs:
$wpdb->update( $wpdb->posts, array(„post_title“ => „Modified Post Title“), array(„ID“ => 5), array(„%s“), array(„%d“) );
\—

„Zdroj »“:http://wp.smashingmagazine.com/2011/09/21/interacting-with-the-wordpress-database/

Odstranění skoku u odkazu „Číst dále“

Mě osobně irituje, když po kliknutí na tlačítko „Číst dále“ mě to automaticky hodí někam doprostřed článku. Nemám rád podobné skoky prohlížeče, já si tam totiž dokážu zascrollovat sám. A protože myslím na svého návštěvníka, tak něco podobného může u mě najít pouze ve spojení s komentáři. Návod, jak situaci s tagem MORE vyřešit nám […]