Custom page with variables in url. Nice url with add_rewrite_rule

I think the add_rewrite_tag() is not needed, and can be replaced with adding the variables to the public query vars directly: // Either directly (in your init hook): $wp->add_query_var( ‘var1’ ); $wp->add_query_var( ‘var2’ ); // Or via a filter: add_filter( ‘query_vars’, ‘wpse12965_query_vars’ ); function wpse12965_query_vars( $query_vars ) { $query_vars[] = ‘var1’; $query_vars[] = ‘var2’; return … Read more

Access the same page from multiple urls (wildcard)

You can use template_include, but before you hook to this filter you must do the following steps: Create page template. e.g: page-target.php <?php /** * Template Name: Page Target */ … Manually query the contents of target-page on page-target.php template, because the global $post will be referencing to your some-prefix-* page. (Optional): Edit and apply … Read more

How to Change 404 page title

I would use the wp_title filter hook: function theme_slug_filter_wp_title( $title ) { if ( is_404() ) { $title=”ADD 404 TITLE TEXT HERE”; } // You can do other filtering here, or // just return $title return $title; } // Hook into wp_title filter hook add_filter( ‘wp_title’, ‘theme_slug_filter_wp_title’ ); This will play nicely with other Plugins … Read more

Use a separate upload folder for custom post attachment upload

I ended up solving it by completely bypassing the wp upload system, so this is how it looks now: /* * Define new upload paths */ $uploadfolder = WP_CONTENT_DIR . ‘/exames’; // Determine the server path to upload files $uploadurl = content_url() . ‘/exames/’; // Determine the absolute url to upload files define(RM_UPLOADDIR, $uploadfolder); define(RM_UPLOADURL, … Read more

Which asset URLs are acceptable in a “vanilla” MU install?

Short Answer example.com/bob/files/picture.jpg is the preferred, canonical URL for images in a WordPress Multisite installation. The two URLs with blogs.dir in the URL are essentially identical, and both leverage the filesystem structure. The path with ‘bob’ exists because you did a sub-directory install, not a subdomain install. Other paths would exist based on your other … Read more

Difference between esc_url() and esc_url_raw()

From the Codex entry for Data Validation: URLs: esc_url( $url, (array) $protocols = null ) (since 2.8) Always use esc_url when sanitizing URLs (in text nodes, attribute nodes or anywhere else). Rejects URLs that do not have one of the provided whitelisted protocols (defaulting to http, https, ftp, ftps, mailto, news, irc, gopher, nntp, feed, … Read more

Change default URL path (/blog/) of blog posts

You can create any structure you want for this on the permalinks settings page in the dashboard. To set it to your example of /blog/title-of-post Simply navigate to Settings -> Permalink. Select the “Custom Structure” radio button and enter blog/%postname%/ into the text field there, then hit the save changes button.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)