Skip to main content
21 votes
Accepted

Add custom options to the wplink dialog

The dialog HTML comes from WP_Editors::wp_link_dialog() but no hooks in there. We could instead use jQuery to append the custom HTML to the link dialog and try to override e.g. the wpLink.getAttrs(), ...
birgire's user avatar
  • 67.4k
10 votes

Using filters to change href of nav menu page link

You are on right track, with few minor kinks. You need to modify $atts and return it. Any arguments after the first one are provided for information and should not be changed. You need to tell ...
Rarst's user avatar
  • 99.7k
9 votes

Redirecting to old domain after migration

Run the following when you are changing domain: UPDATE wp_options SET option_value = 'https://yournew.domain' WHERE option_name = 'siteurl'; UPDATE wp_options SET option_value = 'https://yournew....
crmpicco's user avatar
  • 821
8 votes
Accepted

Removing link '<a>' from '<li>' menu for some "links" without JS

Assuming you're using wp_nav_menu() to display your navigation you could apply a walker that looks for css classes: $items_wrap = '<nav class="...">'; $items_wrap .= '<ul id="%1$s" class="%...
Howdy_McGee's user avatar
  • 20.7k
8 votes
Accepted

How to print translation supported text with HTML URL

Since esc_html_e will escape HTML link (hence will show the HTML anchor as plain text), you'll need to segment the text and escape the non-HTML part with esc_html_e or esc_html__, and print the HTML ...
Fayaz's user avatar
  • 8,937
7 votes
Accepted

How to remove author name and link from a shared link preview?

This might help you. Add this script to functions.php. It will unset author from oembed preview. Remember Discord might already cached your URL. You may not get immediate result. add_filter( '...
Sabbir Hasan's user avatar
  • 1,359
6 votes

Why is there a link tag with rel "profile" pointing to gmpg.org?

This profile enables your site to use the FOAF semantic insertions for richer metadata on your site. FOAF goes for Friend Of A Friend and aims to interconnect in "knowledge nodes" all the personal ...
Ricard Menor's user avatar
6 votes

Redirecting to old domain after migration

Changing wp_options field will help a little, but sometimes your pages, posts and plugins will use absolute references to images and other files. In this case, you'll need to update the entire ...
Tone Williams's user avatar
5 votes

Linking to page with all posts

I know this question was answered years ago, but for those looking for a solution that find this page, there is a MUCH easier solution. Go to Posts > Categories and click on Quickedit for the default ...
Jeremy Caris's user avatar
5 votes

Links redirecting to localhost after migration to server

if anyone comes across with this issue, I resolved it by editing both the 'home' and 'siteURL' fields in the wp-options table of the database on the server (not the localhost one) to replace the '...
Akhil Dobariya's user avatar
5 votes
Accepted

How to create a link to jump to "Leave a comment" part?

The code below should be something similar to what you're looking for Inside the loop template you use for listing blogs (like index.php) you need something like this <a href="<?php ...
Stephen's user avatar
  • 1,304
5 votes
Accepted

How to generate expiring URL?

Ok I came up with this add_action( 'wp_loaded', 'my_create_questionnaire_link'); function my_create_questionnaire_link(){ // this check is for demo, if you go to http://yoursite.demo/?create-my-...
bynicolas's user avatar
  • 2,279
5 votes
Accepted

Count and show Clicks on external links in a single page/post

Yes, it is possible. You can do this with ajax call that updates post meta field before the link is followed. In the example, I used admin and non-admin users who click the link and automatic ...
Faysal Mahamud's user avatar
5 votes
Accepted

Keep getting same permalink with WP_Query?

Don't forget to use esc_url() echo '<a href="'. esc_url( $link ).'">Welcome</a>'; Also try this: get_permalink( get_the_ID() );
kiarashi's user avatar
  • 294
5 votes
Accepted

How to properly insert a link to a template in WordPress?

WordPress doesn't work that way. In WordPress, none of the posts or pages that you visit actually exist anywhere on the disk. The content is grabbed from database and then the template files are ...
Johansson's user avatar
  • 15.3k
4 votes
Accepted

Favorite websites with shortened hyperlinks

Sure, you're looking for the shortcode API. That would enable you to write a short piece of code that does exactly what you want. As easy as this in your functions.php: function wpse246274_wiki( $...
cjbj's user avatar
  • 14.6k
4 votes
Accepted

opening links in new tab using - add_filter( 'the_content', 'make_clickable');

I am not sure if there's a native function for this, but a little regex might help the case: function open_links_in_new_tab($content){ $pattern = '/<a(.*?)?href=[\'"]?[\'"]?(.*?)?>/i'; ...
Ismail's user avatar
  • 1,936
4 votes

Redirect user if it's not logged in

I wouldn't use htaccess for that. What I would do is make a 'download page' template and use it to 'serve' the files. By doing that, I can do a check with is_user_logged_in() Codex and redirect with ...
Marcelo Henriques Cortez's user avatar
3 votes

Add custom options to the wplink dialog

Looking at the core, there's no trace of any filter or action in the wp_link_dialog function, which would have made your life easier... Investigating how others has solved this problem, there's a ...
Capiedge's user avatar
  • 778
3 votes
Accepted

How to list all external URLs that I have posted on my WordPress blog?

The above code had pagination concerns when I wanted to parse each and every page. So, building on the above, plus a kicker to search for links without 'nofollow' attributes, I came up with the ...
pennstump's user avatar
  • 146
3 votes

Internal Links to Pages in PHP?

Do you want to find them by name? If yes then you can <a href="<?php echo site_url('/services'); ?>"> Services </a>
Arttyor's user avatar
  • 41
3 votes

How can I find all internal links that are pointing to post/page?

I found it is easier to use a service like https://validator.w3.org/checklink to check any broken link than checking through wp_posts database. You enter your site url and it will check through all ...
hcheung's user avatar
  • 339
3 votes

Is there any way to set default for "Insert/Edit Link" to "Open link in new window"?

I followed your instructions and was not working at all, because wordpress changed a bit the id of the link. I fixed myself and I created a plugin. <?php /* Plugin Name: Default New Window Link ...
eballo's user avatar
  • 191
3 votes

Using filters to change href of nav menu page link

This will allow you to update the URL for specific menu items. In the case of the OP, "Link Title" would be replaced with "Our Philosophy". This would be placed in your child theme's functions.php ...
dbmpls's user avatar
  • 118
3 votes
Accepted

What is this: data-wplink-url-error="true" and why is it added to my links?

When you're inserting a link in the tinymce editor, there is a piece of javascript that checks whether the link looks like a url. If it doesn't it inserts this string into the anchor tag. Later on in ...
cjbj's user avatar
  • 14.6k
3 votes

Change logo url link

The login_headerurl filter is for changing the logo url of login page, according to the Codex. To change the logo URL of your homepage, you will have to look into your theme's header.php file. You ...
Johansson's user avatar
  • 15.3k
3 votes

Change logo url link

If the theme author is using bloginfo('url') to output the url, then you can do the following. bloginfo('url') is a wrapper for echo get_bloginfo('url') which is a wrapper for home_url() which in ...
Nathan Johnson's user avatar
3 votes
Accepted

programatically change href to onclick=window.open

Parsing HTML with regular expressions is not ideal. A better alternative is to use DOMDocument and DOMXpath; This code uses DOMDocument and DOMXpath to parse and modify the HTML without relying on ...
Dave Romsey's user avatar
  • 17.8k
3 votes
Accepted

Creating a navigation link to my front-page

You can use home_url(), which will point to the Site URL regardless of reading settings and/or what page it is: echo esc_url( home_url( '/' ) );
Milo's user avatar
  • 78.5k

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