Tag Info

Hot answers tagged

3

Yes, this is the intended behaviour: page-{slug}.php - If the page slug is recent-news, WordPress will look to use page-recent-news.php So, simply use a different filename for your templates, like template-contact.php for example. You can find more info about this here: https://codex.wordpress.org/Template_Hierarchy


2

Filter template_include, check if the current post is a product and load the product template. Example: add_filter( 'template_include', function( $template ) { if ( ! is_singular() or ! get_post_meta( get_the_ID(), 'price', true ) ) return $template; return locate_template( 'product-single.php' ); }); How exactly you determine if a post ...


2

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.


1

There might be better ways using filters or apache/nginx rewrites, but here are two ideas to consider from the admin UI point of view (untested): Idea 1: You can always visit /wp-admin/options-general.php change the whole the site url: but I don't think you're looking for that, since this will also change the home url. Idea 2: You might therefore ...


1

$_GET refers literally to ?p=1 part of URL. With pretty permalink if it's empty then there is nothing to access. WordPress processed either case into query variables of WP_Query class. You should use get_query_var() to retrieve things like this, so in this specific case it would probably be get_query_var( 'p' ).


1

There are 3 parts to making this work. Register the post type with correct rewrite slug and archive. We add the %category% rewrite tag to the slug so we can swap in the selected category. We also specify the archive name explicitly. I've omitted the rest of the register_post_type arguments here, the rest can be as-is in your own example. 'rewrite' => ...


1

Did you use it like that?? <a href="<?php get_permalink($id); ?>"><?php the_title($id); ?></a> for use to that foreach($ids as $id){ $link = get_permalink($id); $title = get_the_title($id); $links .= '<a href="'.$link.'">'.$title.'</a>'.'<br/>' ; //$links .= $link . ' <br>'; } get_permalink ...


1

There is nothing happening at one month, and nothing "locks" permalinks. There is no actual difference in the system, the only difference is in the initial multisite configuration interface. When you first define WP_ALLOW_MULTISITE to true, and visit the network screen, you get the initial setup menu which lets you set up the configuration. It looks much ...


1

Here's a simpler take. Only turn off the redirecting if none of the query_vars are present. In this way we get to keep the functionality, without the need to duplicate the logic already at redirect_canonical. add_filter('redirect_canonical', 'no_redirect_on_404', 10, 2); function no_redirect_on_404($redirect_url, $requested_url){ $id = ...


1

Use get_term_link() to get the correct URL for a taxonomy term archive. $list .= "\n\t\t" . '<li><a href="'. get_term_link( $tag ) .'">'.$name.'</a></li>';



Only top voted, non community-wiki answers of a minimum length are eligible