Affichage des articles dont le libellé est Links. Afficher tous les articles
Affichage des articles dont le libellé est Links. Afficher tous les articles

samedi 12 novembre 2016

How to Link to External Links from the Post Title in WordPress



Do you want to add an external link as post title in WordPress? Sometimes you may just want to share a link with your users. Instead of sending them to a post, you may want the post title to link to the other website. In this article, we will show you how to link to external links from the post title in WordPress.


Adding External Link to WordPress Post Title


Method 1: Linking Post Title to an External Link in WordPress using Plugin


This method is easier and is recommended for beginners.


First thing you need to do is install and activate the Page Links To plugin. For more details, see our step by step guide on how to install a WordPress plugin.


Upon activation, simply create a new post or edit an existing one. You will notice the new ‘Page Links To’ meta box below the post editor.


Adding a custom URL in page links to


Click on ‘A custom URL’ to add the link you want to add to post title. Now you can save or publish your post.


That’s all. The post title will now link to the custom URL you provided.


It is not necessary to use it for external links only. You can also use it to send users to different posts and pages on your WordPress site.


Method 2: Add External Link to Post Title Using Code


This method requires you to add code to your WordPress site. You can use this method if you are comfortable with pasting snippets from web into WordPress.


Simply add this code to your theme’s functions.php file or a site-specific plugin.



function print_post_title() {
global $post;
$thePostID = $post->ID;
$post_id = get_post($thePostID);
$title = $post_id->post_title;
$perm = get_permalink($post_id);
$post_keys = array(); $post_val = array();
$post_keys = get_post_custom_keys($thePostID);

if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey=='external_url') {
$post_val = get_post_custom_values($pkey);
}
}
if (empty($post_val)) {
$link = $perm;
} else {
$link = $post_val[0];
}
} else {
$link = $perm;
}
echo '<h2><a href="'.$link.'" rel="bookmark" title="'.$title.'">'.$title.'</a></h2>';
}

This code looks simply looks for a custom field containing your custom URL. If the post has the custom field, then it outputs the post title linked to your URL.


The next step is to replace your theme’s default display of post title with this function. You will find it in archives.php, content.php, category.php and other templates. It would look something like this:



<?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>

You need to replace it with this code:



<?php print_post_title() ?>

The code part is over, now you need to add the external URL to the post. Simply edit the post or create a new one. On the post editor page, look for the custom fields meta box.


If you cannot see the custom fields meta box, then you need to click Screen Options in the top right corner of the screen. This will bring down a menu where you need to check the box next to ‘Custom Fields’.


Show custom fields meta box on the post edit screen in WordPress


You will find the custom fields meta box below the post editor.


Click on ‘Enter New’ and then enter external_url in the ‘Name’ field and the URL you want to add to post title in the ‘Value’ field.


Adding new custom key


You can now save or publish your post. That’s all, your post title will now be linked to the URL you added in the custom field.


Next time you need to add a link, you just need to select the external_url custom field from the drop down menu and enter your external link in the value field.


We hope this article helped you learn how to link to external links from the post title in WordPress. You may also want to see our guide on how to add an external link icon on your WordPress Site.


If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


The post How to Link to External Links from the Post Title in WordPress appeared first on WPBeginner.







How to Remove the Powered by WordPress Footer Links



Do you want to remove the powered by WordPress footer links on your site? Recently one of our readers asked if it was possible to remove footer credits in WordPress themes. In this article, we will show you how to remove the powered by WordPress footer links in your themes.


Remove Powered by WordPress Links


The default WordPress themes use the footer area to display the “Proudly powered by WordPress” link. Many theme developers take this further and add their own credits, so it looks something like “Powered by WordPress. Theme by Company Z”.


But if you’re running a business website, then it doesn’t make any sense to display these credits. Some even think that it makes your website look unprofessional.


Is it legal to remove WordPress footer credit links?


We get this question a lot. Yes, it is absolutely legal to remove footer credits link on your WordPress site.


WordPress is free, and it is released under the GPL license.


In short, that license gives you the freedom to use, modify, and even redistribute WordPress. Any WordPress theme or plugin that you download from the official WordPress.org directory, and even most commercial WordPress themes are also released under the same license.


So you have full rights to do what you please with your website including removing the footer credit links.


Let’s take a look at how to customize your WordPress footer and remove these credit links.


Video Tutorial



If you don’t like the video or need more instructions, then continue reading.


Removing WordPress Powered by Links


There are many ways to remove the WordPress footer credit links, but we only recommend the following 2 ways of doing this.


The Theme Settings Page


Most good theme authors know that their users want to have the option to remove footer credit links. That’s why they make it available in their theme settings area.


Different themes have this setting available under different sections. But the first place to start looking is inside the WordPress theme customizer (Appearance » Customize).


For example, the GetNoticed theme by Michael Hyatt give users the option to customize the footer text as well as disable the credit links.


GetNoticed Footer Credits Setting


Other places that you can look are individual theme’s options pages or inside the Widgets section.


Footer.php Code Method


If your theme does not have the option to remove or modify footer credits from WordPress admin, then your only option is to edit the footer.php code.


You can find this file in your /wp-content/themes/yourtheme/footer.php


Simply open this file in a text editor and search for the footer credit text like “Powered by”, and it will show you the section that you need to remove.


In the default Twenty Sixteen theme for WordPress, the code looks like this:



<div class="site-info">
<?php
/**
* Fires before the twentysixteen footer text for footer customization.
*
* @since Twenty Sixteen 1.0
*/
do_action( 'twentysixteen_credits' );
?>
<span class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span>
<a href="<?php echo esc_url( __( 'https://wordpress.org/', 'twentysixteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentysixteen' ), 'WordPress' ); ?></a>
</div><!-- .site-info -->

You can either remove this text entirely or customize it to suit your needs.


Avoid the CSS Method at All Cost


Now some WordPress tutorial sites may show you a CSS method that uses display: none to hide the footer credit links.


However doing so will put your site’s SEO at risk. Google does not like hiding links with display:none because that’s a technique that spammers use to hide the links from users while still showing it to Google (in hopes of higher rankings).


Your site might get flagged, and it will cause you to lose your search engine rankings.


So whatever you do, do not use the CSS method like this:


#site-info {display:none}

While it looks simple, it’s not good for SEO.


We strongly recommend using the two methods that we showed above. If you cannot do either of those, then we recommend hiring a professional to help you remove your footer credit links or even consider changing your WordPress theme.


We hope this article helped you remove the powered by WordPress footer links. You may also want to check out our guide on how to improve your WordPress security.


If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.


The post How to Remove the Powered by WordPress Footer Links appeared first on WPBeginner.