Last active
June 16, 2019 22:48
-
-
Save Liroo/d67051711a92720a9f8e54e15242ab38 to your computer and use it in GitHub Desktop.
Find the best Barba namespace for your wordpress theme.
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
<?php | |
$barbaNamespace = ''; | |
$post_type = get_post_type(); | |
switch ($post_type) { | |
case 'page': | |
$barbaNamespace = get_query_var('pagename'); | |
if ( !$barbaNamespace && $id > 0 ) { | |
// If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object | |
$post = $wp_query->get_queried_object(); | |
$barbaNamespace = $post->post_name; | |
} | |
break; | |
// here I assume you have a CPT named project, it is my most common CPT name for portfolios | |
case 'project': | |
$barbaNamespace = 'project'; | |
break; | |
default: | |
$barbaNamespace = 'default'; | |
break; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment