Support » Plugin: WPtouch » Custom Post Type permalink not working with WPTouch

  • Resolved TrishaM


    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 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 />
    <?php the_excerpt(); ?>
    </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 ( 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!

    • This topic was modified 11 months ago by  TrishaM.
    • This topic was modified 11 months ago by  TrishaM.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author WPtouch


    Hi @trisham,

    “Why are custom post types not supported easily?”

    Exactly because that – they’re custom. I assume the custom post types on the site are defined in the desktop theme’s functions.php file (or similar). WPtouch/Pro loads its own themes, that are independent of the desktop theme. So anything in the desktop theme can’t be ‘seen’ by WPtouch.

    One way to add this is by defining the custom post types in WPtouch using a child theme. At this time, child themes are only officially supported in WPtouch Pro.

    Or, you can define them in a plugin, that way they’re available site-wide, in both the desktop and mobile themes.

    However, you would still need to add custom templates for the post types (if they’er using any) in WPtouch, which should be done in a child theme. This way your modifications survive updates.


    Emilio Rivera,
    WPtouch Support

    Hi Emilio ( @wptouch ) – thanks for the reply!

    I moved the registration of the CPTs to a separate plugin and that did fix the problem. I have created custom templates for the mobile theme, and I do agree that a child theme is the best solution, but since the free version of WPTouch does not support child themes then the custom template is in the primary theme folder.

    I’m not anticipating updating the WPTouch plugin because we’re working on a new (desktop) theme that will be mobile responsive and won’t require a separate theme for mobile, however I will continue to recommend WPTouch because it’s a terrific plugin that does a great job of allowing websites that don’t have a good mobile-responsive theme to present a good mobile experience to their site visitors.

    Plugin Author WPtouch



    Glad to know you were able to sort things out. Thank you for the follow-up and the feedback. We appreciate it!

    [ Signature deleted ]

    • This reply was modified 9 months, 2 weeks ago by  Jan Dembowski.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post Type permalink not working with WPTouch’ is closed to new replies.