Custom Post Type permalink not working with WPTouch
-
We have a custom post type and a custom template in the plugin’s themes (bauhaus/default) folder, that queries the custom post type and displays a link to each returned post with an excerpt. The template returns the correct posts but the permalink to each post is wrong…..the plugin is leaving out the post type from the URL so that clicks on the post title reverts to the home page instead of the Post.
I’ve tried variations of the_permalink();, get_permalink();, and get_post_permalink();, none of which work.
Here’s my current code:
$args = array( 'post_type' => 'hike', 'meta_key' => 'date_start', 'meta_value' => date('Ymd'), 'meta_compare' => '>=', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'posts_per_page' => -1, ); $myposts = new WP_Query($args); if ( $myposts->have_posts() ) : while ( $myposts->have_posts() ) : $myposts->the_post(); { global $post; $exp_date = strtotime(get_post_meta($post->ID,'date_start',true)); $hikerating = get_post_meta($post->ID,'hike_rating',true); $permalink = get_permalink($post->ID); ?> <div class="hikeentry"> <div class="time"> <div class="month"><?php echo date('M', $exp_date); ?></div> <div class="wkday"><?php echo date('l', $exp_date); ?></div> <div class="day"><?php echo date('d', $exp_date); ?></div> <div class="year"><?php echo date('Y', $exp_date); ?></div> </div> <div class="hikedata"> <h4><a href="<?php echo $permalink; ?>"><?php the_title(); ?></a></h4> <div class="hikemeta"> <div class="left"> <span>Rating:</span> <?php echo $hikerating; ?><br /> </div> </div> <?php the_excerpt(); ?> </div> </div><!-- end .hikeentry -->I also tried hard coding the URL using the slug to form the last part of the permalink and a hard-coded first part ( http://mydomain.com/hike/(slug goes here) ) which *appears* to form a valid URL, but when clicked on still goes to the Home Page.
Why are custom post types not supported easily? I really need some help with this one!
The topic ‘Custom Post Type permalink not working with WPTouch’ is closed to new replies.