Jak omezit listování v příspěvcích pouze na rubriku, ve které je příspěvek

Jednoduchý způsob přímo v šabloně:

/—code php
previous_post_link( ‚%link‘, ‚Prev post in category‘, true );
next_post_link( ‚%link‘, ‚Next post in category‘, true );
\—

V případě, že nechceme zasahovat do šablony (potřebujeme např. upravit listování v rubrice v single.php v Twentyfifteen), stačí vložit do functions.php tento kód:

/—code php
add_filter( ‚get_next_post_join‘, ‚navigate_in_same_taxonomy_join‘, 20);
add_filter( ‚get_previous_post_join‘, ‚navigate_in_same_taxonomy_join‘, 20 );
function navigate_in_same_taxonomy_join() {
global $wpdb;
return “ INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id“;
}

add_filter( ‚get_next_post_where‘ , ‚navigate_in_same_taxonomy_where‘ );
add_filter( ‚get_previous_post_where‘ , ‚navigate_in_same_taxonomy_where‘ );
function navigate_in_same_taxonomy_where( $original ) {
global $wpdb, $post;
$where = “;
$taxonomy = ‚category‘;
$op = (‚get_previous_post_where‘ == current_filter()) ? ‚<' : '>‚;
$where = $wpdb->prepare( „AND tt.taxonomy = %s“, $taxonomy );
if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) )
return $original ;

$term_array = wp_get_object_terms( $post->ID, $taxonomy, array( ‚fields‘ => ‚ids‘ ) );

$term_array = array_map( ‚intval‘, $term_array );

if ( ! $term_array || is_wp_error( $term_array ) )
return $original ;

$where = “ AND tt.term_id IN (“ . implode( ‚,‘, $term_array ) . „)“;
return $wpdb->prepare( „WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = ‚publish‘ $where“, $post->post_date, $post->post_type );
}
\—

„Zdroj »“:http://presscustomizr.com/snippet/restrict-post-navigation-category/

Export rubrik, štítků a uživatelských taxonomií

**WP Export Categories & Taxonomies**
„https://wordpress.org/plugins/wp-export-categories-taxonomies/“:https://wordpress.org/plugins/wp-export-categories-taxonomies/

Simple and basic plugin that let you export Categories, Tags and Taxonomies into a WordPress xml so you can import them in other sites using the WordPress importer tool.

Vyloučení rubriky ze zobrazení přes the_category()

Může se hodit, když nechceme zobrazovat např. nadřazenou rubriku, ale jen podrubriky. Umístíme do functions.php.
/—code php
function the_category_filter($thelist,$separator=‘ ‚) {
// seznam ID rubrik, které se nemají zobrazit
$exclude = array(4, 5);
// create an empty array
$exclude2 = array();

// loop through the excluded IDs and get their actual names
foreach($exclude as $c) {
// store the names in the second array
$exclude2[] = get_cat_name($c);
}

// get the list of categories for the current post
$cats = explode($separator,$thelist);
// create another empty array
$newlist = array();

foreach($cats as $cat) {
// remove the tags from each category
$catname = trim(strip_tags($cat));

// check against the excluded categories
if(!in_array($catname,$exclude2))

// if not in that list, add to the new array
$newlist[] = $cat;
}
// return the new, shortened list
return implode($separator,$newlist);
}

add_filter(‚the_category‘,’the_category_filter‘, 10, 2);
\—

Rich text editor (Tiny MCE) pro popisky tagů. rubrik a dalších taxonomií

**The Rich Text Tags – A TinyMCE Editor for Tags, Categories, and Taxonomies**
„http://wordpress.org/extend/plugins/rich-text-tags/“:http://wordpress.org/extend/plugins/rich-text-tags/

The Rich Text Tags Plugin allows you to edit tag descriptions, category descriptions, and taxonomy descriptions using WordPress‘ built in rich-text editor. Switch between WYSIWYG and HTML editing modes with the click of a link. Use the WordPress uploader to insert images from your computer or site’s Media Library.

Use the WordPress functions tag_description() and category_description() in your theme to show the descriptions. To learn how to show taxonomy descriptions, read more on the plugin page.
Features

– Edit term descriptions with WordPress’s built-in WYSIWYG editor
– Works with custom taxonomies (and custom post types, introduced in WP 3.0)
– Now supports user biography fields!

Zjištění ID rodičovské kategorie

Potřebujete-li v loopu např. ve výpisu příspěvků z rubriky (archivu) zjistit u každého příspěvku ID kořenové rubriky (tedy jsou-li rubriky vnořené), vložte do *functions.php* funkci

/—code php
/*
* Returns ID of top-level parent category, or current category if you are viewing a top-level
*
* @param string $catid Category ID to be checked
* @return string $catParent ID of top-level parent category
*/
function pa_category_top_parent_id ($catid) {
while ($catid) {
$cat = get_category($catid); // get the object for the catid
$catid = $cat->category_parent; // assign parent ID (if exists) to $catid
// the while loop will continue whilst there is a $catid
// when there is no longer a parent $catid will be NULL so we can assign our $catParent
$catParent = $cat->cat_ID;
}
return $catParent;
}
\—

a v loopu si ji pak jen zavoláme pro hodnotu ID:

/—code php
$catid = get_query_var(‚cat‘);
$topcat = pa_category_top_parent_id ($catid);
// a můžeme použít třeba v podmínce
if ($topcat == konkretni-hodnota-id): neco-udelej;
\—

„Zdroj »“:http://alex.leonard.ie/2011/04/20/wordpress-get-id-of-top-level-parent-category/

Přidejte k výpisu rubrik a tagů počet článků

Nastavení zobrazování počtu článků u jednotlivých rubrik a štítků v sidebaru není žádný problém. Stačí zaškrtnout příslušné pole ve vkládaných widgetech. Zvládne to i začátečník. Pokud je ovšem chcete vypisovat i na samotné stránce, tak vás čeká poněkud těžší práce. Je to třeba upravit přímo v šabloně. A nač to je vlastně dobré? Aby čtenáři… Číst dále

Rozbalovací seznam rubrik

**Folding Category List (FoCaL)**
„http://wordpress.org/extend/plugins/folding-category-widget/“:http://wordpress.org/extend/plugins/folding-category-widget/

As your blog gets more and more posts you will inevitably create more categories to keep them organised. Eventually your categories will take up more room on your screen and scroll across many pages.

Folding Category List for WordPress is a plug-in that will only show the top level categories and the current sub-categories. This will save a lot of space on your sidebars for other widgets. Additionally, you can animate the menu as either a drop down horizontal menu or an accordion style vertical menu, both with cool jQuery animations.

– jQuery Animation: Use Suckerfish or Superfish to animate drop down menus! – js included in plugin, just activate from control panel!
– jQuery Animation: Use Simple jQuery Accordion to animate vertical menus! – js included in plugin, just activate from control panel!
– SEO friendly: Add nofollow and descriptions to links.
– Multi-widget: Have as many lists as you need.
– Multi-category: If posts are in multiple categories, you can still control which one to expand, or expand all of them.
– International: Plugin is compatible with translation plugins (qTranslate).
– Control: Change order by category name, id, description, post count or use My Category Order plugin for total control.
– Pages: Expand category list on pages using custom fields.
– Style: There are lots of different options for CSS tags allowing designers to create unique menus.

„Použito na autorově webu »“:http://azuliadesigns.com/focal/

Řazení rubrik

**My Category Order**
„http://wordpress.org/extend/plugins/my-category-order/“:http://wordpress.org/extend/plugins/my-category-order/
„http://geekyweekly.com/mycategoryorder“:http://geekyweekly.com/mycategoryorder

Allows you to set the order in which categories will appear in the sidebar. Uses a drag and drop interface for ordering. Adds a widget with additional options for easy installation on widgetized themes.

Případně třeba v sidebaru upravit takto:

/—code php
wp_list_categories(‘orderby=order&title_li=’)
\—

**Category Order**
„http://wordpress.org/extend/plugins/order-categories/“:http://wordpress.org/extend/plugins/order-categories/
„http://wpguy.com/plugins/category-order/“:http://wpguy.com/plugins/category-order/

The Order Categories plugin allows you to easily reorder your categories the way you want via drag and drop.

V šablonách od „Elegant Themes“:https://wordpresso.ovx.cz/wp-et.php je implementováno řazení podle názvu nebo ID, je tedy potřeba v šabloně *header.php* vymazat
/—code php
sort_column=$artsee_sort_cat&sort_order=$artsee_order_cat
\—

v řádku s 

/—code php
wp_list_cats(„sort_column=…);
\—

Korektně ale se šablonou Pure Type funguje pouze plugin *Category order*.

Zobrazení nejnovějších příspěvků z vybrané rubriky

**Category Posts Widget**
„http://wordpress.org/extend/plugins/category-posts/“:http://wordpress.org/extend/plugins/category-posts/
„http://jameslao.com/2009/12/30/category-posts-widget-3-0/“:http://jameslao.com/2009/12/30/category-posts-widget-3-0/

Category Posts Widget is a light widget designed to do one thing and do it well: display the most recent posts from a certain category.

Features:

– Support for displaying thumbnail images via WP 2.9’s new post thumbnail feature.
– Set how many posts to show.
– Set which category the posts should come form.
– Option to show the post excerpt and how long the excerpt should be.
– Option to show the post date.
– Option to show the comment count.
– Option to make the widget title link to the category page.
– Multiple widgets.

Implementováno na tomto webu.

Odstranění rubriky z url

**WP No Category Base**
„http://wordpress.org/extend/plugins/wp-no-category-base/“:http://wordpress.org/extend/plugins/wp-no-category-base/
„http://wordpresssupplies.com/wordpress-plugins/no-category-base/“:http://wordpresssupplies.com/wordpress-plugins/no-category-base/

This plugin will completely remove the mandatory ‚Category Base‘ from your category permalinks ( e.g. myblog.com/category/my-category/ to myblog.com/my-category/ ).

Implementováno na tomto webu.

*Alternativa*

**No category parents**
„http://wordpress.org/extend/plugins/no-category-parents/“:http://wordpress.org/extend/plugins/no-category-parents/

This plugin will completely remove the mandatory ‚Category Base‘ and all the parents from your category permalinks (e.g. /category/parent-category/my-category/ to /my-category/).

Odstranění rubriky z URL lze dosáhnout i zápisem v souboru .htaccess:

/—code php
RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]
\—

Případně:

/—code php
// Remove category base
add_filter(‚category_link‘, ‚no_category_parents‘,1000,2);
function no_category_parents($catlink, $category_id) {
$category = &get_category( $category_id );
if ( is_wp_error( $category ) )
return $category;
$category_nicename = $category->slug;

$catlink = trailingslashit(get_option( ‚home‘ )) . user_trailingslashit( $category_nicename, ‚category‘ );
return $catlink;
}

// Add our custom category rewrite rules
add_filter(‚category_rewrite_rules‘, ‚no_category_parents_rewrite_rules‘);
function no_category_parents_rewrite_rules($category_rewrite) {
//print_r($category_rewrite); // For Debugging

$category_rewrite=array();
$categories=get_categories(array(‚hide_empty’=>false));
foreach($categories as $category) {
$category_nicename = $category->slug;
$category_rewrite[‚(‚.$category_nicename.‘)/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$‘] = ‚index.php?category_name=$matches[1]&feed=$matches[2]‘;
$category_rewrite[‚(‚.$category_nicename.‘)/page/?([0-9]{1,})/?$‘] = ‚index.php?category_name=$matches[1]&paged=$matches[2]‘;
$category_rewrite[‚(‚.$category_nicename.‘)/?$‘] = ‚index.php?category_name=$matches[1]‘;
}
// Redirect support from Old Category Base
global $wp_rewrite;
$old_base = $wp_rewrite->get_category_permastruct();
$old_base = str_replace( ‚%category%‘, ‚(.+)‘, $old_base );
$old_base = trim($old_base, ‚/‘);
$category_rewrite[$old_base.’$‘] = ‚index.php?category_redirect=$matches[1]‘;

//print_r($category_rewrite); // For Debugging
return $category_rewrite;
}

// Add ‚category_redirect‘ query variable
add_filter(‚query_vars‘, ‚no_category_parents_query_vars‘);
function no_category_parents_query_vars($public_query_vars) {
$public_query_vars[] = ‚category_redirect‘;
return $public_query_vars;
}
// Redirect if ‚category_redirect‘ is set
add_filter(‚request‘, ‚no_category_parents_request‘);
function no_category_parents_request($query_vars) {
//print_r($query_vars); // For Debugging
if(isset($query_vars[‚category_redirect‘])) {
$catlink = trailingslashit(get_option( ‚home‘ )) . user_trailingslashit( $query_vars[‚category_redirect‘], ‚category‘ );
status_header(301);
header(„Location: $catlink“);
exit();
}
return $query_vars;
}
\—

The RSS feeds, however, don’t seem to work with this shorter url, and still require the long-form url. (Not sure if there’s a fix for that.) Also, it doesn’t change the post permalink. It’s just the category permalink that changes. Paste the code below into your functions.php file.