Title: Arha Routes
Author: Atte Liimatainen
Published: <strong>05. listopada 2019.</strong>
Last modified: 15. svibnja 2020.

---

Pretraga dodataka

Dodatak **nije testiran s zadnje 3 glavna izdanja WordPressa**. Možda ga se više
ne održava ili pruža podršku i možda ima probleme sa kompatibilnošću s novijim inačicama
WordPressa.

![](https://s.w.org/plugins/geopattern-icon/arha-routes.svg)

# Arha Routes

 Od [Atte Liimatainen](https://profiles.wordpress.org/attlii/)

[Preuzmi](https://downloads.wordpress.org/plugin/arha-routes.zip)

 * [Detalji](https://hr.wordpress.org/plugins/arha-routes/#description)
 * [Recenzije](https://hr.wordpress.org/plugins/arha-routes/#reviews)
 * [Razvoj](https://hr.wordpress.org/plugins/arha-routes/#developers)

 [Podrška](https://wordpress.org/support/plugin/arha-routes/)

## Opis

WordPress plugin that helps to serve content through REST routes and gives
 customizability
to developers through filters.

### Available Routes

 * `/wp-json/arha/v1/post`
 * `/wp-json/arha/v1/page`
 * `/wp-json/arha/v1/options`
 * `/wp-json/arha/v1/archive`

### Example queries

 * `/wp-json/arha/v1/post?post_type=POST_TYPE&slug=SLUG`
 * `/wp-json/arha/v1/page?path=PATH`
 * `/wp-json/arha/v1/options`
 * `/wp-json/arha/v1/archive?post_type=POST_TYPE&posts_per_page=POSTS_PER_PAGE&paged
   =PAGED&orderby=ORDERBY&order=ORDER`

### tax_query and meta_query in archive-route

 * `tax_query` and `meta_query` are supported and they work how the query is built
   for it in `new WP_Query()`
 * both needs their values to bes passed in as stringified json

### Multiple post_types in archive-route

 * To pass multiple post_types in archive-route, use syntax that lets PHP read GET-
   param as an array. https://stackoverflow.com/a/9547490

### Filters

 * To exclude querying specific post types from `post`– and `archive`-routes, you
   
   can use following filters:
 * `
    add_filter(‘arha_routes/archive_excluded_post_types’, ‘exclude_post_types’);
   add_filter(‘arha_routes/post_excluded_post_types’, ‘exclude_post_types’);

function exclude_post_types($excluded_post_types) {
 $excluded_post_types = [‘post’];
return $excluded_post_types; } `

 * To format `post`-route’s post before it’s served to client, use `arha_routes/
   format_post`-filter
    ` add_filter(‘arha_routes/format_post’, ‘format_post’);

function format_post($post) {
 return $post; } `

 * To format `page`-route’s post before it’s served to client, use `arha_routes/
   format_page`-filter
    ` add_filter(‘arha_routes/format_page’, ‘format_page’);

function format_page($page) {
 return $page; } `

 * To format `archive`-route’s posts before they are served to client, use `arha_routes/
   format_archive_post`-filter
 * `add_filter('arha_routes/format_archive_post', 'format_archive_post');
    function
   format_archive_post($post) { return $post; }
 * `options`-route returns empty result by default. To add content to it, use `arha_routes/
   format_options`-filter
    ` add_filter(‘arha_routes/format_options’, ‘format_options’);

function format_options($options) {
 return $options; } `

 * By default Arha Routes returns only published content with post-, page- and archive-
   route, this can be modified by adding following filters.
    ` // for archive route
   add_filter(‘arha_routes/allowed_post_statuses_archive’, ‘allowed_post_statuses’);//
   for post route add_filter(‘arha_routes/allowed_post_statuses_post’, ‘allowed_post_statuses’);//
   for page route add_filter(‘arha_routes/allowed_post_statuses_page’, ‘allowed_post_statuses’);
   function allowed_post_statuses($post_statuses) { // … change post_statuses array
 * return $post_statuses;
    } ` After adding setting up these filters, request can
   include “post_status” parameter and it will be compared to $post_statuses array.

### SearchWP

Arha Routes supports SearchWP-plugin, which lets WP users to make keyword search
engine for their content.

Activating SearchWP-plugin adds optional keyword-search functionality to `archive`-
route. This is done by adding `s=KEYWORD` to the route
 – Example: `/wp-json/arha/
v1/archive?post_type=products&posts_per_page=10&paged=1&orderby=date&order=ASC&s
=monitor`

### Polylang

Arha Routes supports Polylang-plugin, which allows users to create content in multiple
languages.

Activating Polylang changes how endpoints work:

 * All routes require additional `lang`-param
    - Example: `/wp-json/arha/v1/archive?post_type=products&posts_per_page=10&paged
      =1&orderby=date&order=ASC&lang=en`
 * `page`-route doesn’t support language prefix in path
    - Example: Permalink `/zh/info`, use like this `/wp-json/arha/v1/page?path=/
      info&lang=zh`
    - Example: Permalink `/en/info/test`, use like this `/wp-json/arha/v1/page?path
      =/info/test&lang=zh`
 * `options`-route passes `lang`-param forward to `arha_routes/format_options`-filter
   `
   add_filter('arha_routes/format_options', 'format_options', 10, 2); function format_options(
   $options, $lang) { return $options; }

### Polylang + SearchWP

In order to make these two plugins work together, you need to add extra plugin to
WP installation.

https://searchwp.com/extensions/polylang-integration/

## Recenzije

Nema recenzija za ovaj dodatak.

## Suradnici i Programeri

“Arha Routes” je softver otvorenog koda. Sljedeće osobe su doprinijele ovom dodatku.

Suradnici

 *   [ Atte Liimatainen ](https://profiles.wordpress.org/attlii/)

[Prevedite “Arha Routes” na svoj jezik.](https://translate.wordpress.org/projects/wp-plugins/arha-routes)

### Zainteresirani ste za razvoj?

[Pregledajte kôd](https://plugins.trac.wordpress.org/browser/arha-routes/), pogledajte
[SVN spremište](https://plugins.svn.wordpress.org/arha-routes/)ili se pretplatite
na [dnevnik razvoja](https://plugins.trac.wordpress.org/log/arha-routes/) od [RSS](https://plugins.trac.wordpress.org/log/arha-routes/?limit=100&mode=stop_on_copy&format=rss).

## Meta

 *  Version **1.5**
 *  Zadnje ažuriranje **prije 6 godina**
 *  Aktivnih instalacija **10+**
 *  WordPress inačica ** 5.0 ili viša **
 *  Testirano do **5.3.27**
 *  PHP inačica ** 7.1 ili viša **
 *  Language
 * [English (US)](https://wordpress.org/plugins/arha-routes/)
 * Oznaka
 * [bilingual](https://hr.wordpress.org/plugins/tags/bilingual/)[endpoint](https://hr.wordpress.org/plugins/tags/endpoint/)
   [language](https://hr.wordpress.org/plugins/tags/language/)[multilingual](https://hr.wordpress.org/plugins/tags/multilingual/)
   [rest](https://hr.wordpress.org/plugins/tags/rest/)
 *  [Napredni pogled](https://hr.wordpress.org/plugins/arha-routes/advanced/)

## Ocjena

No reviews have been submitted yet.

[Your review](https://wordpress.org/support/plugin/arha-routes/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/arha-routes/reviews/)

## Suradnici

 *   [ Atte Liimatainen ](https://profiles.wordpress.org/attlii/)

## Podrška

Želite nešto reći? Potrebna vam je pomoć?

 [Pregledaj forum za podršku](https://wordpress.org/support/plugin/arha-routes/)