예제 #1
0
function taxonomy_slug_rewrite($wp_rewrite)
{
    /* Initialize array to hold rules */
    $rules = array();
    /* Get all custom taxonomies */
    $taxonomies = get_taxonomies(array('_builtin' => false), 'objects');
    /* Get all custom post types */
    $post_types = getDivisionPostTypes();
    /* Loop through custom post types */
    foreach ($post_types as $post_type) {
        /* Loop through custom taxonomies */
        foreach ($taxonomies as $taxonomy) {
            /* Loop through objects this taxonomy is assigned to */
            foreach ($taxonomy->object_type as $object_type) {
                /* Replace underscores with hyphens */
                $regex_object_type = preg_replace('/_/i', '-', $object_type);
                /* If the object type (with hyphens) is equal to the slug for a post type, do stuff */
                if ($regex_object_type == $post_type->rewrite['slug']) {
                    /* Get all terms for this taxonomy */
                    $terms = get_categories(array('type' => $object_type, 'taxonomy' => $taxonomy->name, 'hide_empty' => 0));
                    /* For each term, do stuff */
                    foreach ($terms as $term) {
                        /* Add a rewrite rule for each term that uses the post type slug */
                        $rules[$regex_object_type . '/category/' . $term->slug . '/?$'] = 'index.php?' . 'taxonomy=' . $term->taxonomy . '&term=' . $term->slug;
                    }
                }
            }
        }
    }
    /* Add custom rules to WordPress rewrite rules */
    $wp_rewrite->rules = $rules + $wp_rewrite->rules;
}
예제 #2
0
    <li class="side-nav_item side-nav_item-first">
      <a href="<?php 
echo home_url();
?>
" <?php 
if (is_front_page()) {
    echo 'class="active"';
}
?>
><i class="fa fa-home"></i>Home</a>
    </li>

  <?php 
/* Get menu pages based on division post types */
$menu_pages = getDivisionPostTypes();
/* For each menu page, do stuff */
foreach ($menu_pages as $menu_page) {
    $menu_page_type = $menu_page->name;
    // Get menu page type
    $menu_page_archive_link = get_post_type_archive_link($menu_page_type);
    // Get menu page archive link
    ?>

    <li class="side-nav_item side-nav_item-first">

      <a href="<?php 
    echo $menu_page_archive_link;
    ?>
" <?php 
    echo $menu_page_archive_link == $currentURL || $menu_page_archive_link == $currentURL . '/' ? 'class="active"' : '';
예제 #3
0
<?php

/**
 * The template part for displaying the home page content.
 *
 * @package WGIki
 */
?>

<div class="cards cards-divisions">

<?php 
/* Get all division post types */
$divs = getDivisionPostTypes();
/* Loop through each division */
foreach ($divs as $div) {
    $div_label = $div->label;
    // Get the name
    $div_type = $div->name;
    // Get the type
    $div_archive = get_post_type_archive_link($div_type);
    // Get link to archive
    $div_slug = $div->rewrite['slug'];
    // Get the slug
    ?>

  <div class="card-container grid-33 tablet-grid-50 mobile-grid-100">
    <div class="card card-stack card-division">
      <a class="card_link" href="<?php 
    echo $div_archive;
    ?>
예제 #4
0
파일: footer.php 프로젝트: pdhoopr/wgiki
 *
 * Contains the closing of the #content div and all content after
 *
 * @package WGIki
 */
?>
    </div><!-- #content -->
    <footer id="colophon" class="site-footer" role="contentinfo">

    <?php 
if (is_user_logged_in()) {
    ?>
      <div class="footer">
        <div class="grid-container">
          <?php 
    $footer_divs = getDivisionPostTypes();
    // Get division post types
    /* If division post types are not empty, do stuff */
    if (!empty($footer_divs)) {
        ?>

            <div class="footer_managers footer_col grid-100 tablet-grid-100 mobile-grid-100 grid-parent">
              <div class="grid-100">
                <h5 class="footer_title">Content Managers</h5>
              </div>

            <?php 
        /* For each division, do stuff */
        foreach ($footer_divs as $footer_div) {
            $footer_div_role = 'manager_' . $footer_div->name;
            // Get manager role for this division