How to make menu items active based on hash

This can be accomplised fairly easy by checking the URL then setting the appropriate link to active. That can be accomplished by the following… var hash = window.location.hash.substr(1); // Get the text after the hash $(‘a[href=”#’ + hash + ‘”]’).addClass(‘active’); // Set the correct link to active However, there are some things to consider. Someone … Read more

Get url from file uploaded in Media Library

If understand your question correctly, I think this can get the job done. Use get_attachment_link instead of wp_get_attachment_url and then echo the title. <?php $attachment_id = 2582; $attachment_page = get_attachment_link( $attachment_id ); ?> <a href=”https://wordpress.stackexchange.com/questions/255020/<?php echo $attachment_page; ?>”><?php echo get_the_title($attachment_id ); ?></a>

Check what is at URI (post, archive, etc…)

Retrieve “type” of query from url: Previous suggestions As noted in the linked answer, there’s url_to_postid(). This will just get you the ID of the object at that endpoint. Long story short, this function will only return an ID and then run a new \WP_Query to get the post type object from the DB and … Read more

get_site_url is not returning anything?

The functions that start with “get_” return the value to what’s calling it. So you would do <a href=”https://wordpress.stackexchange.com/questions/11893/<?php echo get_site_url(); ?>”> instead to print out the URL.

permalink for category pages and posts

There’s currently no way in core to get the current archive / category / tag / custom taxonomy URL. I have a patch waiting for that to be added right here. For now though, you could just use the code in the last patch on that ticket: <?php /* Get the current archive link * … Read more

How to update media links in WordPress after migration?

As mentioned in the comments under your question, some data in the WordPress database is serialized and therefore not possible to change with a simple find and replace. You should read through the Moving WordPress section of the codex. Specifically the Changing Your Domain Name and URLs portion. I usually use a plugin or a … Read more

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