Why ids in urls don’t work but slugs do?

Because the tag query variable expects the value to the terms slug. It’ll be looking for the term with slug ’15’ (which presumably doesn’t exist). And, yes its quite frustrating that wp_dropdown_categories() uses the ID as the value, rather than the slug. This is because it was originally used only for categories (for which IDs … Read more

open all .docs in word online

I’m not sure this question is WordPress-related. It sounds like it might be handled via .htaccess redirect, or a browser extension. That said: you could try to use the wp_get_attachment_url filter, that is applied to the URL returned by wp_get_attachment_url(). For example: function wpse95271_filter_wp_get_attachment_url( $url ) { if ( 0 === stripos( strrev( $url ), … Read more

home_url(); showing current page instead of site address

Since you didn’t post actual code in your question, I can only speculate. However, a common problem is that, when calling home_url(), it is not echoed. The value of the function is returned, rather than echoed, so it must be explicitly echoed by the code. I’m guessing you have something like this: <a href=”https://wordpress.stackexchange.com/questions/95730/<?php home_url(); … Read more

How to change image url?

Go into your WordPress Dashboard > Settings > Media and then untick the option that says Organize my folders into Month and Year based folders This will make it look like: http://example.com/wp-content/uploads/imagename.jpg Then to take it further you need to update you config.php file and add in either this line: define( ‘UPLOADS’, ‘image/’.’files’ ); This … Read more

How can I get the page url slug when ‘post_name’ returns an id?

Try this : $menu = get_term( $locations[$theme_location], ‘nav_menu’ ); $menu_items = wp_get_nav_menu_items($menu->term_id); foreach( $menu_items as $menu_item ) { $link = $menu_item->url; $title = $menu_item->title; $slug = basename($menu_item->url); } Pass the whole permalink to the basename function, which will automatically process the URL and give us only the slug.

WP Nav menu append to url

I found the solution modifying the behaviour of wp_nav_menu with the wp_get_nav_menu_items-filter. Here’s a somewhat complete example: class ModifyLinkFilter { protected $_prio = 10; protected $_args; public function __construct($addargs = array(), $prio = 10) { $this->_args = $addargs; $this->_prio = $prio; if(!empty($addargs)) { $this->register(); } } public function register() { add_filter(‘wp_get_nav_menu_items’, array($this, ‘on_nav_items’), $this->_prio, 3); … Read more

How to redirect visitor to a custom URL using PHP code in functions.php

First, it is hard to believe that wp_redirect isn’t working, below some (example) code how to use it: function wpse101952_redirect() { global $post; if( /*SOME CONDITIONAL LOGIC*/ ) { //examples: is_home() or is_single() or is_user_logged_in() or isset($_SESSION[‘some_var’]) wp_redirect( /*SOME SPECIFIC URL*/ ); exit(); } } add_action( ‘template_redirect’, ‘wpse101952_redirect’ ); Second, there would be the question … Read more

A way to change image urls in post to cdn image url?

You can parse via regex for images in the_content; but is always load and slowly. Maybe you change the url of images, after post_save in database or change the current posts inside the database and create an custom CDN. Its the fast way and all caching plugins has the break, that she must parse the … Read more

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