Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* In include/post-translations.php */
- <td><?php echo esc_html($language->name);?></td>
- <td>
- <?php
- $this->dropdown_posts( array(
- 'post_type' => get_post_type(),
- 'selected' => intval($value),
- 'select_name' => 'post_tr_lang['.esc_attr($language->slug).']',
- 'exclude' => $post_ID
- ) );
- ?>
- </td>
- /* Here is the dropdown_posts function: */
- function dropdown_posts($args) {
- $defaults = array(
- 'depth' => 0,
- 'echo' => 0,
- 'numberposts' => -1,
- 'sortby' => 'post_title',
- 'order' => 'ASC'
- );
- $r = wp_parse_args( $args, $defaults );
- $posts = get_posts( $r );
- $options_html = walk_page_dropdown_tree( $posts, 0, $r );
- printf('<select name="%s"><option value="">%s</option>%s</select>',
- $r['select_name'],
- __('None'),
- $options_html);
- }
- /* And finaly -- you should check for the surpress_filters to be off when modifying the queries via pre_get_posts: */
- // filters posts according to the language
- function pre_get_posts($query) {
- // Don't run if suppress_filters is on.
- if ( isset( $query->query_vars[ 'suppress_filters' ] ) && $query->query_vars[ 'suppress_filters' ] == true )
- return $query;
- /* [...] */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement