Vícenásobné řazení v QUERY podle custom fields

/—code php
$q = new WP_Query( array(
‚meta_query‘ => array(
‚relation‘ => ‚AND‘,
‚state_clause‘ => array(
‚key‘ => ‚state‘,
‚value‘ => ‚Wisconsin‘,
),
‚city_clause‘ => array(
‚key‘ => ‚city‘,
‚compare‘ => ‚EXISTS‘,
),
),
‚orderby‘ => array(
‚city_clause‘ => ‚ASC‘,
‚state_clause‘ => ‚DESC‘,
),
) );
\—

„Zdroj »“:https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query/

Metadata v taxonomiích

**Category and Taxonomy Meta Fields**
„https://wordpress.org/plugins/wp-custom-taxonomy-meta/“:https://wordpress.org/plugins/wp-custom-taxonomy-meta/

Plugin to add custom meta fields within built in and custom taxonomies. Simply add the desired fields by going through WP-admin -> Settings ->Taxonomy Meta .
You can add following fields with category/taxonomy:
– Image
– Input Text
– Textarea
– Checkbox

**Taxonomy Metadata**
„https://wordpress.org/plugins/taxonomy-metadata/“:https://wordpress.org/plugins/taxonomy-metadata/

This plugin implements the metadata infrastructure for taxonomy terms, so you can add custom metadata (by key) to tags, categories, and other taxonomies. The majority of the code is from sirzooro’s submission to the WordPress Core Trac. The rest of the plugin is simply some hacky glue to make this work without modifying the Core. It does not implement any UI for taxonomy term metadata.

**Meta for taxonomies**
„https://wordpress.org/plugins/meta-for-taxonomies/“:https://wordpress.org/plugins/meta-for-taxonomies/

Add meta for any taxonomies. Meta is attached to taxonomy context and not terms, this way allow to have metas different for the same term on 2 different taxonomies. This plugin don’t any interface on WordPress ! Only somes methods for developpers.

**Taxonomy Images**
„https://wordpress.org/plugins/taxonomy-images/“:https://wordpress.org/plugins/taxonomy-images/

Associate images from your media library to categories, tags and custom taxonomies.

**Carbon Fields**
„https://wordpress.org/plugins/carbon-fields/“:https://wordpress.org/plugins/carbon-fields/

Developer-oriented library for WordPress custom fields for all types of WordPress content.
Carbon fields is a plugin that can be used as a library for easy creation of custom fields in the WordPress administration panel.
Can be created for post types, taxonomy terms, users, comments, options, navigation menus and even widgets.

Uživatelské taxonomie, přidávání uživatelských polí k taxonomiím

„Custom user taxonomies »“:http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress

*

To add a custom field to your custom taxonomy, add the following code to your theme’s functions.php:
/—code php
// A callback function to add a custom field to our „presenters“ taxonomy
function presenters_taxonomy_custom_fields($tag) {
// Check for existing taxonomy meta for the term you’re editing
$t_id = $tag->term_id; // Get the ID of the term you’re editing
$term_meta = get_option( „taxonomy_term_$t_id“ ); // Do the check
?>

term_id“ );
// Return the value for the „presenter_id“ custom field
$presenter_data = get_userdata( $presenter_custom_fields[presenter_id] ); // Get their data
\—

To see what data is stored inside the custom fields you created, add the print_r function to your template, then preview it:
/—code php
‚; print_r( $presenter_custom_fields ); echo ‚

‚;
?>
\—

To keep it dynamic, we are passing in the „presenter_id“ field of our $presenter_custom_fields variable. Now, to see what data you have to work with, use print_r again:
/—code php
‚; print_r( $presenter_data ); echo ‚

‚;
?>
\—
„Zdroj: How To Add Custom Fields To Custom Taxonomies »“:http://sabramedia.com/blog/how-to-add-custom-fields-to-custom-taxonomies

***

To add a form field to the Edit Category screen we’ll use the edit_category_form_fields action hook available in WordPress:
/—code php
term_id, $cat_featured ) ) {
$featured_id = $cat_featured[$tag->term_id] ;
}
?>

The post ID that will be the featured post when viewing this category.


\—
The above code will add a single text field (Featured Post ID) to the Edit Category screen.

Now we need to save the input to our option array. To capture the ID when a category is updated we’ll use the edited_category action hook like so:

/—code php

\—
As you can see we are saving the Category ID and Featured Post ID as a single associative array option value in WordPress named category_featured. As you add Featured Post ID values to each of your categories they will be added to this array and saved in WordPress.

„Save Taxonomy Meta Data as an Options Array in WordPress »“:http://strangework.com/2010/07/01/how-to-save-taxonomy-meta-data-as-an-options-array-in-wordpress/

***

„How to Add Custom Meta Fields to Custom Taxonomies in WordPress »“:http://www.wpbeginner.com/wp-tutorials/how-to-add-additional-custom-meta-fields-to-custom-taxonomies/

„Adding Custom Meta Fields to Taxonomies »“:https://pippinsplugins.com/adding-custom-meta-fields-to-taxonomies/

„How To Add Custom Fields To Custom Taxonomies»“:http://sabramedia.com/blog/how-to-add-custom-fields-to-custom-taxonomies

„WordPress: Adding custom fields to taxonomies »“:http://www.journal.deviantdev.com/wordpress-adding-custom-fields-to-taxonomies/

„WordPress Taxonomies Extra Fields the easy way »“:https://en.bainternet.info/wordpress-taxonomies-extra-fields-the-easy-way/

„Hooking WordPress Taxonomy Changes With The Plugins API »“:https://www.dougv.com/2014/06/hooking-wordpress-taxonomy-changes-with-the-plugins-api/

„Extending WordPress Taxonomies »“:http://www.sitepoint.com/extending-wordpress-taxonomies/

Rychlá nebo hromadná editace uživatelských polí

**Saving custom fields in quick or bulk edit mode in WordPress**
„http://wpdreamer.com/2012/03/manage-wordpress-posts-using-bulk-edit-and-quick-edit/“:http://wpdreamer.com/2012/03/manage-wordpress-posts-using-bulk-edit-and-quick-edit/

One of the most cool features when managing WordPress posts, is the ability to batch edit multiple posts at once or quickly edit one post to perform a simple task such as adding a tag. Learn how to extend WordPress’ Quick Edit and Bulk Edit to retrieve and save the value of your custom fields.

**Plugin Custom Bulk/Quick Edit**
„http://wordpress.org/plugins/custom-bulkquick-edit/“:http://wordpress.org/plugins/custom-bulkquick-edit/
„https://github.com/michael-cannon/custom-bulkquick-edit“:https://github.com/michael-cannon/custom-bulkquick-edit
„How do I add custom fields to my bulk/quick edit page »“:https://aihrus.zendesk.com/entries/24800411-How-do-I-add-custom-fields-to-my-bulk-quick-edit-page-
„How do you configure options »“:https://aihrus.zendesk.com/entries/24911342

Pozor, do functions.php *může* být nutné přidat:

/—code php
add_filter( ‚manage_post_posts_columns‘, ‚my_manage_post_posts_columns‘ );
function my_manage_post_posts_columns( $columns ) {
$columns[‚custom_field_name‘] = esc_html__( ‚Nazev sloupce v administraci‘ ); // pozor, název sloupce musí být bez diakritiky
return $columns;
}
\—

a teprve **po přidání** tohoto kódu je třeba zpřístupnit pole v nastavení pluginu.

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

„Using Custom Fields In Your WordPress Template »“:http://return-true.com/2010/06/using-custom-fields-in-your-wordpress-template/

/—code php
// 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“:http://codex.wordpress.org/Function_Reference/post_meta_Function_Examples for the usage of the add_post_meta, delete_post_meta, update_post_meta, and get_post_meta functions.

Správa uživatelských polí vč. vytváření metaboxů

**Advanced Custom Fields**
„http://wordpress.org/plugins/advanced-custom-fields/“:http://wordpress.org/plugins/advanced-custom-fields/
„http://www.advancedcustomfields.com/“:http://www.advancedcustomfields.com/

– Visually create your Fields
– Select from multiple input types (text, textarea, wysiwyg, image, file, page link, post object, relationship, select, checkbox, radio buttons, date picker, true / false, repeater, flexible content, gallery and more to come!)
– Assign your fields to multiple edit pages (via custom location rules)

Handy add-on:

**Advanced Custom Fields Limiter**
„https://wordpress.org/plugins/advanced-custom-fields-limiter/“:https://wordpress.org/plugins/advanced-custom-fields-limiter/

Insert JavaScript character limiters in Advanced Custom Fields. You set a limit for each field, and a character counter will appear next to them in the admin interface.

A lot of other ACF extending plugins available »“:http://wordpress.org/plugins/search.php?q=Advanced+Custom+Fields

Jak přidat vlastní pole do uživatelského profilu a zobrazit je na stránce

„This technique“:http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields will allow you to easily add new user profile fields that your blog’s users can use to input more information about themselves. In this tutorial, I’ll show you how to add an input box for a Twitter username and how to display it on your site.

In „this article“:http://www.wpbeginner.com/wp-tutorials/how-to-display-an-author-list-with-avatars-in-wordpress-contributors-page/ we will show you how you can create a contributors page which will display a list of authors with avatars or userphoto and any other information that you like.

The user profile of WordPress can be fairly easily adapted to add your own values​​. So you can add the necessary *custom fields* according to your requirements. „Here is“:http://wpengineer.com/2173/custom-fields-wordpress-user-profile/ how you do it.

Most free themes do not have a custom ***author.php*** file, WordPress automatically callback to ***archive.php*** or ***index.php*** when someone views the author profile page. The problem with that is that it will only list all the posts written by the author, and it provides no personal information about the author. It is recommended that you copy your ***archive.php*** and save it as ***author.php*** and modify it.

To get user’s (author’s) data from his/her profile, use „get_userdata function“:http://codex.wordpress.org/Function_Reference/get_userdata:

/—code php
first_name;
$last_name = $user_info->last_name;
$email = $user_info->user_email;
$description = $user_info->description;
$roles = $user_info->roles;
$username = $user_info->user_login;
?>
\—

obdobně funkce „get user by“:http://codex.wordpress.org/Function_Reference/get_user_by.

Jednoduché přidání vlastních vstupních polí

Plugin vhodný spíše pro mírně pokročilejší uživatele WordPressu umožní vytvoření vlastních vstupních polí (nastavitelná alternativa uživatelských polí – custom fields) k článkům a stránkám. Podoba vytvořených vstupních polí pro vkládání určených hodnot je v podstatě libovolná, samozřejmě v závislosti na vašich potřebách a nastaveních v administraci pluginu (Nastavení – Simple Fields). Můžete si vždy pro […]

Pohodlné vytváření uživatelských polí

**Verve Meta Boxes**
„http://wordpress.org/extend/plugins/verve-meta-boxes/“:http://wordpress.org/extend/plugins/verve-meta-boxes/
„http://www.avenueverve.com/verve-meta-boxes/“:http://www.avenueverve.com/verve-meta-boxes/

Verve Meta Boxes is a robust custom fields plugin with an intuitive, polished interface that allows for creation of text, textarea, image, file, date, select, radio, and checkbox custom fields for posts and/or pages.

Values for custom fields are stored in wp_postmeta and can be accessed in templates through standard WordPress functions such as: the_meta, get_post_meta, get_post_custom, get_post_custom_values, etc.

*Alternativy*

**Advanced Custom Fields**
„http://wordpress.org/plugins/advanced-custom-fields/“:http://wordpress.org/plugins/advanced-custom-fields/

Fully customise WordPress edit screens with powerful fields.

– Visually create your Fields
– Select from multiple input types (text, textarea, wysiwyg, image, file, page link, post object, relationship, select, checkbox, radio buttons, date picker, true / false, repeater, flexible content, gallery and more to come!)
– Assign your fields to multiple edit pages (via custom location rules)
– Easily load data through a simple and friendly API
– Uses the native WordPress custom post type for ease of use and fast processing
– Uses the native WordPress metadata for ease of use and fast processing

*Using ACF in templates:*

get_field(‚field_name‘) – returns the value
the_field(‚field_name‘) – displays the value

„Automated Exporting for Advanced Custom Fields »“:http://seanbutze.com/automated-exporting-for-advanced-custom-fields/
A way to make Advanced Custom Fields automatically export all fields to a PHP file. Export is initiated whenever an admin publishes a new field group or saves changes to an existing field group.

„Programmatically define custom fields, prevent custom field changes or deletion »“:http://code.tutsplus.com/tutorials/create-a-simple-crm-in-wordpress-advanced-custom-fields–cms-20049

„Adding Sortable Columns to WP_List_Table“:http://code.tutsplus.com/tutorials/create-a-simple-crm-in-wordpress-adding-columns-to-wp_list_table–cms-20065

„Using the Advanced Custom Fields Plugin to create a custom home page in WordPress »“:http://www.elliotcondon.com/using-the-advanced-custom-fields-plugin-to-create-a-custom-home-page-in-wordpress/

Vytváření uživatelských polí v administračním rozhraní

**Flutter**
„http://wordpress.org/extend/plugins/fresh-page/“:http://wordpress.org/extend/plugins/fresh-page/
„http://flutter.freshout.us/“:http://flutter.freshout.us/

Flutter is a feature rich WordPress CMS plugin that focuses on easy templating for the developer and simplifies content management for the admin by creating custom write panels that can be fully customized (radio buttons, file uploads, image uploads, checkboxes, etc).

Flutter also includes power image manipulation (automatic resizing, cropping, watermarking, etc), edit in place (works instantly!), and modulation of your themes.