This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Filter Elasticsearch posts by current language | |
add_filter( 'ep_formatted_args', function($formatted_args, $args) { | |
$formatted_args['post_filter']['bool']['must'][] = [ | |
'term' => [ | |
'lang' => pll_current_language() | |
] | |
]; | |
return $formatted_args; | |
}, 10, 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# redirect sub folder to new sub domain | |
location ~ /sub { | |
rewrite ^(/sub/)(.*)$ http://sub.domain.com/$2; | |
} | |
# redirect main site to new domain | |
location ~ / { | |
return 302 http://domain.com$request_uri; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function render_template_part( $template, $args ) { | |
extract( $args ); | |
include( locate_template( $template . '.php' ) ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function show_page_instead_of_archive_page( $request ) { | |
if ( key_exists( 'category', $request ) ) { | |
$slug = $request['category']; | |
$queried_post = get_page_by_path( $slug, OBJECT, 'page' ); | |
if ( $queried_post ) { | |
$request['page_id'] = $queried_post->ID; | |
unset( $request['category'] ); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add editor support for posts page. | |
* If the posts page has content, the editor will turn to Gutenberg. | |
* | |
* @param object $post Post object. | |
* @return void | |
*/ | |
function add_editor_for_posts_page( $post ) { | |
if ( ! isset( $post->ID ) || absint( $post->ID ) !== absint( get_option( 'page_for_posts' ) ) ) { | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fix_breadcrumb_archive_links_lang( $links ) { | |
foreach ( $links as $key => $link ) { | |
if ( isset( $link['ptarchive'] ) ) { | |
$post_type_object = get_post_type_object( $link['ptarchive'] ); | |
$links[$key]['url'] = get_post_type_archive_link( $link['ptarchive'] ); | |
$links[$key]['text'] = $post_type_object->label; | |
} | |
} |