Tag Info

Hot answers tagged

2

Use get_template_directory_uri(): $url = get_template_directory_uri() . '/images/myimage.jpg'; This function will always return the correct path to your theme. If you want to hide/shorten that URL, you could use an endpoint, maybe img. The downside is, you load the complete WordPress for each image request. Or use mod_rewrite: RewriteRule ...


2

Redirects are GET requests usually, and the browser doesn’t send the POST data for those. That’s not something WordPress can change. You could create a session, or – better – process the POST data first, then redirect. In your plugin, you could do: add_action( 'plugins_loaded', 'process_post_data', 0 ); function process_post_data() { // Read raw POST ...


1

The parameter you are using is wrong. There is no set_front parameter when you register a Custom Post Type. The appropriate parameter is with_front. 'with_front' => bool Should the permastruct be prepended with the front base. (example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/). Defaults to true ...


1

You could override your query with pre_get_posts in functions.php: function add_all_fruits_to_category($query) { $catnames = $query->get('category_name'); if ($catnames == 'fruits') { $query->set('category_name', $catnames . ',bananas,apples,pears'); } } add_action('pre_get_posts', 'add_all_fruits_to_category');


1

I think you're taking the wrong approach in terms of data structure. You should create a custom taxonomy called Genres, and bind your movies CPT to the Genres custom taxonomy, and then select which Genres the movie belongs to. To address questions about your existing code. single-XXX.php template is used to display content from the CPT called XXX. So in ...


1

one way you could do this with an internal WordPress rewrite, which would then set a query var you could check when enqueueing your javascript, and pass that data via localize script. so first, rewrite rule to intercept requests to gallery/ with something appended, load the page named gallery, and set the query var gallery_id to whatever was in the URL. ...


1

To change all author URLs one would normally change the author base, however, since you want multiple author bases, we'll have to do things a bit differently. There are two parts to this - The first part is getting WordPress to recognize incoming requests for your custom author pages and route them properly. To do this we'll add two new rewrite rules that ...



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