0

We have multiple magazine titles on our website and I'm looking to code subdirectories to show certain info. For example:

  • website.com/title1/pdf
  • website.com/title2/pdf
  • website.com/title3/pdf

The 'title' page contains custom fields with additional info (in this case the url to a pdf file)... I want Wordpress to understand that if someone tried to go to ANY subdirectory (in this case) named 'pdf' that it will fire a particular template file (that handles displaying the information).

The key is that I need to be able to know that is a 'child' of the title so that I can get the correct data points... but I also might just be able to look at the url and grab the title's slug to get that info.

  • Have you tried something where we can help you? – cybmeta Feb 24 '15 at 19:41
  • I'm not sure what you mean... I'll have no problem writing the code to actually handle it, I just have no idea how to get wordpress to trigger a particular file based on a subdirectory name. – Brian Miksic Feb 24 '15 at 19:45
  • see this answer. – Milo Feb 24 '15 at 19:47
  • 1
    I meant that "I need this and also be able to do this" is not a good question format; you should show us what you have tried or at least what you have investigated. Sorry if I was rude, it was not my intention. The answer linked by Milo is what I had in mind for this question. Try it and let us know if you need further help. – cybmeta Feb 24 '15 at 19:56
  • Thanks, no worries. Milo's post has me on the right track, but so far not working. it's in the functions of the child theme... is that correct? Then, here is the code I have function wpa_read_endpoint(){ add_rewrite_endpoint( 'pdf', EP_PERMALINK | EP_PAGES ); } add_action( 'init', 'wpa_read_endpoint' ); function wpa_read_template( $template = '' ) { global $wp_query; if( ! array_key_exists( 'pdf', $wp_query->query_vars ) ) return $template; $template = locate_template( 'pdfPage.php' ); return $template; } add_filter( 'single_template', 'wpa_read_template' ); – Brian Miksic Feb 24 '15 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.