Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I wrote this code for 2 custom post types to link back to their respective index
pages from the single post view. It works. However the "Portfolio" and "Artwork" will have multiple pages and I am unclear on what to append to this code to recognize those additional pages as they are created by the user. The page name progression is (for example) portfolio/page/2/, portfolio/page/3/ etc, but all single post breadcrumbs are linking back to the first custom post type index page. Any help is so appreciated but please be concise because my coding skills and Wordpress knowledge are intermediate at best.

global $post;  
  $type = get_post_type($post->ID);  
  if($type == 'portfolio'){  
echo '<a href="' . 'http://www.foo.com/portfolio'  . '">' . 'Portfolio' .  '</a>' . $markup;
  } else if($type == 'artwork'){
echo '<a href="' . 'http://www.foo.com/artwork'  . '">' . 'Artwork' .  '</a>' . $markup;
}}
share|improve this question
    
What do you want breadcrumb to link to? Page of the archive the post is currently on? That's a little unorthodox, I don't think I've seen (or would have expected) breadcrumb link working like that. –  Rarst Oct 20 '13 at 10:47
    
Yes, what I am trying to do may be a little unconventional but it works and it's creative, no? I am trying to add to this code additional breadcrumb links to the correct index page of /page/2/, page/3/, I thought I made myself clear on that. My apologies if not, and thanks for looking into it. Anyone have any suggestions? –  Emp FX Oct 21 '13 at 19:38
    
Hm. This is interesting since WP is made for resolving "which posts are on page X", but doesn't have anything (that I can think of) for "on which page post Y is". –  Rarst Oct 21 '13 at 19:48
1  
Rather that "unrealistic" I would put it like "prone to be extremely fragile" solution and I am hesitant to just come up with something quick and hardcoded that would be non-reusable. –  Rarst Oct 21 '13 at 20:20
    
It's a breadcrumb so I am not too concerned about fragility. Is there no code that will recognize the additional index pages? Will anyone lend their insight? –  Emp FX Oct 22 '13 at 20:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.