Define orderby in url

adding this in the functions.php file works. Just remember to re-save your permalinks & empty the cache a few times to see the changes. add_action( ‘init’, ‘wpse13483_init’ ); function wpse13483_init() { add_rewrite_rule( ‘category/(.+?)/orderby/([^/]+)?/?$’, ‘index.php?category_name=$matches[1]&orderby=$matches[2]&order=asc’, ‘top’ ); add_rewrite_rule( ‘category/(.+?)/orderby/([^/]+)/order/([^/]+)?/?$’, ‘index.php?category_name=$matches[1]&orderby=$matches[2]&order=$matches[3]’, ‘top’ ); // with pagination; add_rewrite_rule( ‘category/(.+?)/orderby/([^/]+)/order/([^/]+)/page/([0-9]{1,})?/?$’, ‘index.php?category_name=$matches[1]&orderby=$matches[2]&order=$matches[3]&paged=$matches[4]’, ‘top’ ); }

locate_template with multiple categories?

The code you posted is looping through all the categories that the post is assigned. The foreach constructs a string representing every possible template file that it wants to check for and assigns them all to $template. The locate_template() function will go through the $templates array and return the first one of them that actually … Read more

Wrong links in WordPress?

Go to Settings, then General Settings, then enter the correct url for your WordPress Address (URL). Perhaps you need to change your Site Address too. Source: The WordPress Codex: http://codex.wordpress.org/Settings_General_Screen If this isn’t the case, but the category links are bad, edit the category slug. Go to Posts, then Categories, select article and edit the … Read more

How can I pass a variable to a page with a SEF url?

You have to either work it out with the WP_Rewrite class or add this to the .htaccess file Options +FollowSymLinks RewriteEngine On RewriteRule ^sermon/(.*)/ /sermon?name=$1 [L] UPDATE Forgot to mention that the htaccess code is supposed to be above the wordpress generated htaccess code

Insert custom ID into wp_get_attachment_link

You have to supply a argument count when adding the filter callback, and add the arguments you are expecting to receive to your callback function. Looking at the wp_get_attachment_link source you can tell that 6 arguments is supplied when applying the filters (the link markup and $id, $size, $permalink, $icon, $text). Here’s how you could … Read more

How to always rewrite author archive page URL even if the author does not have a post

We managed this by hijacking the default author template and setting up our own. Set up a new url rewrite for team members: add_action(‘init’, function () { global $wp_rewrite; $wp_rewrite->author_base=”team”; $wp_rewrite->author_structure=”https://wordpress.stackexchange.com/” . $wp_rewrite->author_base. ‘/%author%’; }); In the template we then use: $uid = get_query_var(‘author’); to get the user’s id. From there you can build out … Read more

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