26
votes
Accepted
Get parent page url to show up when it is in child pages
You can use something like this to get the parent page URL (and show its page title):
<?php if ( $post->post_parent ) { ?>
<a href="<?php echo get_permalink( $post->post_parent ); ?...
- 1,152
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(), ...
- 65.6k
13
votes
Accepted
Redirecting to old domain after migration
My issue is resolved, I am posting this as an answer so that someone else can benefit out of it.
My issue was, siteurl and homeurl were not updated, so I have placed define('RELOCATE',true); in my wp-...
- 473
11
votes
Redirecting to old domain after migration
I had the same problem (works fine now), here is what i done
instead of try to access to the admin panel whit yoursite.com/wp-admin i tried with yoursite.com/wp-login.php and it took me to the admin ...
- 119
9
votes
Accepted
How to get a page url by a page id?
You're probably getting that error because WordPress doesn't have the $wp_rewrite global loaded yet for some reason. Either something deactivated it, or you're trying to run those functions before ...
- 1,657
9
votes
Accepted
How to use wpLink without editor?
There is not ethical way of doing this. But still there is a way to do this. WordPress wrote wpLink script keeping in mind that editor is there but still WordPress handle when editor is not there (...
- 4,734
9
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 ...
- 98.6k
8
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....
- 791
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="%...
- 20.2k
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 ...
- 8,659
7
votes
How to get current page menu item name instead of full menu item list
Within each menu item, object_id holds the ID of whatever object
the menu item refers to. This will be a post / page / CPT / term ID. If it's a custom link, the ID refers to itself. (If you want to ...
- 77.3k
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 ...
5
votes
Adding different classes to anchor in navigation menu
you can follow the below Steps :
Step 1 : In the wp-admin, go to Appearance -> Menus,put the class on the menu item here "CSS Classes (optional)". If you can't see the "CSS Classes (optional)" in the ...
- 151
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 ...
- 61
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 '...
5
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 ...
- 51
5
votes
Accepted
Is there a simple way to just insert a link to an image (without inserting an image)?
I found a solution based on the code of this page:
https://core.trac.wordpress.org/ticket/22180
All attachment files have a post status of 'inherit'. So first you need to add "inherit" as one of the ...
- 3,213
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 ...
- 1,294
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-...
- 2,259
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 ...
- 1,020
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() );
- 294
4
votes
External Links Not Working
This question is really too localized to get a solid answer and will most likely get closed. Here's a quick guide to narrow down what the issue is - but the fact that I can click the links just fine ...
- 20.2k
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( $...
- 14k
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';
...
- 1,908
4
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 ...
- 15k
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 ...
4
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( '...
- 1,287
3
votes
Why is there a link tag with rel "profile" pointing to gmpg.org?
As asked on the .org support forums
XFN is a HTML profile which describes the meaning of extra semantic
data that can be added to the rel attribute of outbound links.
If you specify ...
- 55.7k
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 ...
- 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>
- 41
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
links × 838permalinks × 84
posts × 71
menus × 69
customization × 56
urls × 56
images × 52
php × 48
plugins × 44
pages × 41
categories × 37
functions × 32
custom-post-types × 27
filters × 23
css × 21
navigation × 21
comments × 20
redirect × 18
widgets × 17
taxonomy × 17
html × 17
author × 17
custom-field × 16
tinymce × 16
plugin-development × 14