*/
define( 'GLM_CUSTOM_POST_TYPE', 'france_tour' );
+define( 'GLM_CUSTOM_DETAIL_PAGE', 'tour-detail' );
define( 'GLM_CUSTOM_TOUR_SINGLE', 'Tour' );
define( 'GLM_CUSTOM_TOUR_PLURAL', 'Tours' );
define( 'GLM_CUSTOM_CATEGORY_NAME', 'glm_custom_category' );
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
- 'rewrite' => $rewrite,
+ 'rewrite' => false,
'capability_type' => 'page',
'register_meta_box_cb' => 'glm_custom_add_metaboxes',
);
return $output;
}
-
+function glm_custom_detail_shortcode( $atts ) {
+ global $post;
+ extract( shortcode_atts( array( 'limit' => '10' ), $atts ) );
+ ob_start();
+ glm_custom_show_tour();
+ $output = ob_get_contents();
+ ob_end_clean();
+ return $output;
+}
/**
* Function glm_custom_list_tours
*
$tour->end = true;
}
//$cat->href = '?glm_custom_category=';
- $tour->href = site_url( '/' . GLM_CUSTOM_POST_TYPE . '/' . $tour->post_name .'/' );
+ $tour->href = site_url( '/' . GLM_CUSTOM_DETAIL_PAGE . '/' . $tour->post_name .'/' );
++$iterator;
}
include 'views/list_tours.php';
* @access public
* @return void
*/
-function glm_custom_show_tour( $prod_id ) {
+function glm_custom_show_tour() {
global $wpdb, $wp;
- $tour = get_post( $prod_id );
+ $tour_slug = get_query_var('tour', '');
+ $tour = get_page_by_path( $tour_slug, ARRAY_A, GLM_CUSTOM_POST_TYPE );
+ echo '<pre>$tour: ' . print_r($tour, true) . '</pre>';
include 'views/tour_detail.php';
return;
}
return;
}
add_shortcode( GLM_CUSTOM_POST_TYPE, 'glm_custom_shortcode' );
+add_shortcode( GLM_CUSTOM_POST_TYPE . '-detail', 'glm_custom_detail_shortcode' );
$rules = get_option( 'rewrite_rules' );
-if ( ! isset( $rules['(' . GLM_CUSTOM_POST_TYPE . ')/([^/]*)$'] ) ) {
+if ( ! isset( $rules['(' . GLM_CUSTOM_DETAIL_PAGE . ')/([^/]*)$'] ) ) {
add_filter( 'rewrite_rules_array', function( $rules ){
$newrules = array();
- $newrules[''] = 'index.php?pagename=$matches[1]&tour=$matches[2]';
+ $newrules['(' . GLM_CUSTOM_DETAIL_PAGE . ')/([^/]*)$'] = 'index.php?pagename=$matches[1]&tour=$matches[2]';
return $newrules + $rules;
} );
} );
}
add_filter( 'query_vars', function( $vars ) {
- array_push( $vars, 'glm_custom_id' );
+ array_push( $vars, 'tour' );
return $vars;
} );
-
<?php
$args = array(
- 'orderby' => 'parent',
- 'hierarchical'=> true,
+ 'orderby' => 'parent',
+ 'hierarchical' => true,
);
-$relatives = wp_get_post_terms($product->ID, 'michsci_category', $args);
+$relatives = wp_get_post_terms( $tour->ID, GLM_CUSTOM_CATEGORY_NAME, $args );
+echo '<pre>$relatives: ' . print_r($relatives, true) . '</pre>';
?>
<div class="small-12 medium-6" id="productBreadcrumbs">
<?php echo '<a href="'. get_permalink(510) . '">' . Products . '</a>'." > "; ?>
-<?php foreach($relatives as $relative){
- echo '<a href="'. '?michsci_category=' . $relative->term_id . '" >' . $relative->name . "</a>" . " > ";
-} ?>
- <?php echo $product->post_title . "<br>"; ?>
+<?php if ( isset( $relatives ) ) {
+ foreach ( $relatives as $relative ) {
+ echo '<a href="'. '?michsci_category=' . $relative->term_id . '" >' . $relative->name . "</a>" . " > ";
+ }
+}?>
+ <?php echo $tour->post_title . "<br>"; ?>
</div>
-<h2><?php echo $product->post_title; ?></h2>
+<h2><?php echo $tour->post_title; ?></h2>
<div class="row">
<div class="productImage small-12 medium-4 columns">
- <?php echo get_the_post_thumbnail($product->ID, 'large'); ?>
+ <?php echo get_the_post_thumbnail($tour->ID, 'large'); ?>
</div>
<div class="features small-12 medium-4 columns">
- <?php
- echo '<h2> Features </h2>';
- $key_value = get_post_custom_values('miproduct_features', $product->ID);
- foreach($key_value as $key=>$value){
+ <?php
+ echo '<h2> Features </h2>';
+ $key_value = get_post_custom_values('glm_custom_features', $tour->ID);
+ if ( $key_value ) {
+ foreach ($key_value as $key=>$value) {
$shortcode_output = do_shortcode($value);
print $shortcode_output;
- }?>
+ }
+ }
+ ?>
</div>
<div id="relatedFiles" class='small-12 medium-4 columns'>
<h3> Related Files </h3>
<?php
- $key_value = get_post_custom_values('miproduct_related_products', $product->ID);
+ $key_value = get_post_custom_values('glm_custom_related_products', $tour->ID);
+ if ( $key_value && is_array( $key_value ) ) {
foreach($key_value as $key=>$value){
$shortcode_output = do_shortcode($value);
print $shortcode_output;
+ }
}?>
<div class="gallery ">
<?php echo '<h4><a class="galleryLink" href="#glm_gallery"> Product Gallery </a></h4>'; ?>
$args = array(
"hide_empty"=>false
);
- $tags = wp_get_post_terms($product->ID,'michsci_tag', $args);
+ $tags = wp_get_post_terms($tour->ID,GLM_CUSTOM_TAG_NAME, $args);
foreach ($tags as $tag){ ?>
<?php echo '<a id="' . $tag->slug . '"href="'. get_permalink(510) . '">'. $tag->name . '</a>' . "<br>"; ?>
<?php }?>
</div>
<div class="description small-12 medium-7 columns">
<?php
- setup_postdata( $product );
- the_content();
+ setup_postdata( $tour );
+ echo apply_filters('the_content', $tour->post_content);
?>
</div>