How to link the title adding a permalink?

Following your code strictly you’d want … $dl .= ‘<dt><a href=”‘.get_permalink($wp_query->post->ID).'”>’ . $wp_query->post->post_title . ‘</a></dt>’; … but you are using the WP_Query object in a very atypical way. You are sort-of brute forcing your way through the Loop instead of using the methods and template functions built into the core. For example: while ( $query->have_posts() … Read more

Can variables be used to rewrite a Custom Post Type permalink? [duplicate]

filter “pre_post_link” to change the permalink rule, the first attribute is the rule set to the administrator and the second is the element which is to form the link function my_pre_post_link( $permalink, $post, $leavename ) { // filtered by post_type, returns the format permalink if( $post->post_type != ‘book’ ) return ‘/bookis_custom/%postname%’; return $permalink; } add_filter( … Read more

Can WP give a value a post ID?

Add a rewrite rule and extra query vars to handle incoming requests, direct the rewrite rule to a single page post type, create a custom page template for that page, then do whatever querying you need using the query vars set by your rewrite rule.

Media/attachment urls don’t redirect with fake URL structure

Milo got me on the right track. If anyone else happens to have this issue the code I used is: /** * Redirect broken attachment links to 404 */ function ww_404_broken_links(){ global $wp_query; if(is_attachment()){ $attachment_path = get_attached_file( get_the_ID() ); //If the file doesn’t exist on the server show 404 if(!file_exists($attachment_path)){ $wp_query->set_404(); status_header( 404 ); get_template_part( … Read more