Domanda

Stiamo lavorando a un plugin in cui qualsiasi utente connesso ha la possibilità di presentare un nuovo "passo", o il tipo di posta standard di stato personalizzato di "passo". Una volta che il passo è nel sistema, dall'altro gli utenti registrati possono votare l'idea, di volontariato a partecipare, o un commento sulla storia in corso.

E 'stato semplice per elencare tutti i post pubblicati su una singola vista interrogando il database per i post con post_status != 'publish'. Mi piacerebbe impostarlo in modo sia loggato e unlogged-nei visitatori possono scegliere attraverso sul titolo e visualizzare il post su una singola vista pure. comportamento WordPress default è di restituire un 404 se non si dispone di autorizzazioni sufficienti. Credo che i permessi visualizzazione vengono gestiti nella query oggetto , e non vedo un modo semplice per disinserire loro.

Tutte le idee creative? Grazie in anticipo.

È stato utile?

Soluzione

ha risposto alla mia domanda proprio su questo. Come si è visto, è stato piuttosto semplice in WordPress 2.9.2. Fondamentalmente, applicato un filtro a 'the_posts' il che sarebbe un'altra query se l'oggetto era vuoto. Perché stiamo guardando i messaggi che non sono stati pubblicati, abbiamo bisogno di usare la nostra SQL personalizzati pure. Cercando di utilizzare l'oggetto WP_Query sarà, beh, è ??messo in un ciclo ricorsivo senza fine.

Altri suggerimenti

If you're using WP 3.0+ you should be able to use the register_post_status() method to register the new status as public. I don't see it in the codex yet, but below is what is documented:

/**
 * Register a post type. Do not use before init.
 *
 * A simple function for creating or modifying a post status based on the
 * parameters given. The function will accept an array (second optional
 * parameter), along with a string for the post status name.
 *
 *
 * Optional $args contents:
 *
 * label - A descriptive name for the post status marked for translation. Defaults to $post_status.
 * public - Whether posts of this status should be shown in the admin UI. Defaults to true.
 * exclude_from_search - Whether to exclude posts with this post status from search results. Defaults to true.
 *
 * @package WordPress
 * @subpackage Post
 * @since 3.0.0
 * @uses $wp_post_statuses Inserts new post status object into the list
 *
 * @param string $post_status Name of the post status.
 * @param array|string $args See above description.
 */
function register_post_status($post_status, $args = array()) {....

Based on this, you should just be able to call:

function add_pitch_status() {
    register_post_status('pitch', array('public'=>true));
}
add_action('init', 'add_pitch_status');
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top