Google Search Completes Rollout of Link Spam Update – WP Tavern

[ad_1] Google announced today that it has completed its rollout of the link spam update, which was started a month ago. In an effort to combat sites using spammy links to manipulate rankings, the search engine has developed more effective ways to identify and nullify link spam across multiple languages. The update took a couple weeks longer than anticipated but the algorithmic changes that re-assess the ranking of improperly qualified links has now been fully rolled out. Commercial linking can be differentiated from link spam by specifying the appropriate rel attribute. For example, affiliate links must be identified to the search engine by  rel=”sponsored” in order to not trigger any negative effects from the most recent update. Website owners and content creators should be aware of the search engine’s requirements when publishing affiliate links or sponsored/guest posts. While it is appropriate and ethical to disclose commercial links in the content of the post, this is no longer sufficient for Google. A post on the Google Search Central blog warns that this update carries a more strict response for sites that do not properly qualify commercial links: When we detect sites engaging in either publishing or acquiring links with excessive sponsored and guest posting without proper link tags, algorithmic and manual actions may be applied, similar to affiliate links. WordPress users who rely on plugins to manage sponsored and affiliate links will want to check to ensure they support the proper tagging for commercial links. Pretty Links, a link management and tracking plugin used by more than 300,000 WordPress sites, added support for the sponsored rel tag in version 3.1.0, along with sponsored toggle support in the block and TinyMCE editors. ThirstyAffiliates, another popular plugin active on more than 40,00 installs, has a global setting for adding rel attribute tags to links, which can also be adjusted on a per-link basis. The are many other affiliate link management, tracking, and cloaking plugins out there that may not have been updated with settings for easily designating relattributes in links. Those who do not want to have negative effects from the link spam update may need the ability to bulk update their links to comply. If you rely on a link management plugin, it’s a good idea to check the plugin’s settings, and alternatively the plugin’s changelog, to see what features are supported. Like this: Like Loading… [ad_2] Source link

Continue reading

How to Link to a Page Section in WordPress Nav Menus

[ad_1] It’s pretty common in WordPress: wanting to link to a section of a page. I remember fondly my first time [stares wistfully into the middle distance]. This Quick Guide explains how to do that, and how to then add that link to a navigation menu. Need to link users to a specific heading within an article? Sometimes you might want your WordPress navigation menu items to link directly to a page section that sits in the middle of a larger page, rather than simply to the top of the page. For example: instead of creating a nav menu link to a Contact page, how do I create a menu link to the Contact section of my homepage? Being able to create WordPress menu links to page sections is especially important on one-page websites, or on multi-page sites that have long scrolling homepages or sales pages. Either of these types of website might have, for example, “How it Works,” “Demo,” “Testimonials,” and “Buy Now” sections all on the same page. To link to a page section, you’ll need to create a WordPress menu link to an anchor: a link embedded in your page content. Anchors are one of the web’s oldest technologies, and they still work great. Fortunately, assigning an anchor to a page section, and then linking to that anchor from your WordPress navigation menu, is not tricky at all. This quick tutorial video from Fred shows you how. if you’re a “visual learner.” And here’s a quick text summary if you’d rather learn how to link to a page section in WordPress without a video 😉 How To WordPress: Link to a section of page Give the item you want to link to an id attribute—for example, <h2 id=”target-element”>Section Title</h2>. This id attribute is the element’s HTML anchor. If you’ve got the Gutenberg/Block editor running, pictured at right is what it’ll look like. You’ll notice that this label is called “HTML anchor” in this interface. In the underlying HTML, it’ll look like an id. 🤓 In the Menu area in either wp-admin or the Customizer, create a new Custom Link to add to your navigation menu. Set the Custom Link to point to the page on which the content lives, plus the # character, plus the value of the element’s id attribute—for example, https://mysite.com/about-us#target-element. Save your changes to the menu, and test the link from a few pages to make sure it works. And that’s it! Creating WordPress menu links to page sections using anchors can be a very helpful way to orient your site’s visitors, so give it a try. [ad_2] Source link

Continue reading

Add Custom Link to All Posts Screen Based on Post Meta Data

[ad_1] TL;DR: This article outlines the code needed to add a custom link on the All Posts screen that uses a custom piece of post metadata. Note: A few months ago, I wrote an article on how to add a custom view to the All Posts screen. This article is not all together the same, but not all together different. Think of it as a more detailed and perhaps for more practical implementation of the concept. Assume that you have a standard post type or a custom post type and you’re going to simply filter by a headline that you define using a mechanism that allows you to save data to the post_metadata table. For example, let’s say that you have a post and it as a piece of meta data with: a meta_key with the value of article_attribute a meta_value with the value of headline And you want to use this information to add a new Headlines link that automatically filters everything out except articles with that metadata. Here’s how to do it. Custom Link on All Posts Screen Before getting started, it’s worth noting that there are two ways to go about tackling this problem: We could add the link at the top of the All Posts page first and then add the functionality for filtering the data second, Or we can do it the other way around where we add the backend logic first then add the All Posts page link. I’m going to opt to start with the second option. There’s no reason why it has to be done this way. It’s my preference. First, I need to hook into the pre_get_posts hook provided by WordPress. I’m not going to be using any namespaced classes or prefixed functions in this example (given that I’ve covered that content enough on this site), but I’ll have demo plugin for this linked at the bottom of the post. Anyway, I’ll start off by adding an anonymous function attached to the aforementioned hook: add_action( ‘pre_get_posts’, function ( WP_Query $query ) { // … } ); Notice that the anonymous function accepts a single argument which is a reference to the current instance of WP_Query that’s running on the page. If you’re not familiar with that class, then I’d recommend reading any of these articles or the Developer Resources page. In the function, I need to check for the presence of a meta_value in the query string. This is easy to do thanks to the filter_input function provided by PHP. add_action( ‘pre_get_posts’, function ( WP_Query $query ) { $meta_value=”headline”; if ( filter_input( INPUT_GET, ‘meta_value’ ) === $meta_value ) { $query->set( ‘meta_key’, ‘article_attribute’ ); $query->set( ‘meta_value’, $meta_value ); } } ); This hook will look to see if the headline value is key for the meta_value key in the query string. If so, it then adds a meta_key and meta_value to the instance of WP_Query which will instruct WordPress to retrieve all of the posts with just that metadata. After that I need to add a a link to the top of the All Posts page to trigger this functionality. To do this, I’ll leverage the views_edit-posts hook. This function will accept an array of anchors that will be displayed at the top of the page. I refer to these as $views so that’s what the function will accept when I stub it out: add_action( ‘views_edit-post’, function ( array $views ) { // … return $views; } ); Note that it’s important to return the array back to WordPress so that it knows what to render even if no modification is made. First, I need to determine if I’m currently on the custom page. If so, then I need to add the proper attributes to the anchor added to the top of the page: // Determine if we’re looking at the Headlines page. $attributes=”class=”””; if ( filter_input(INPUT_GET, ‘meta_value’) === ‘headline’ ) { $attributes=”class=”current aria-current=”page””; } After that, I need to actually add the Headlines view to the page. This will require the use of several functions: array_push for adding a new link to the list of $views sprintf for securely adding a new string add_query_arg for adding a set of custom query arguments to the current page. The next section of code will look like this: // Build the anchor for the ‘Headlines’ view and add it to $views. array_push( $views, sprintf( ‘<a href=”https://tommcfarlin.com/custom-link-all-posts-screen/%1$s” %2$s>%3$s <span class=”count”>(%4$s)</span> </a> ‘, add_query_arg([ ‘post_type’ => ‘post’, ‘post_status’ => ‘all’, ‘meta_value’ => ‘headline’, ], ‘edit.php’), $attributes __(‘Headlines’), count( /* … */ ); ); But I’m not done yet. Notice specifically that I’m making a call to count at the end of the function. This is so that I can properly display the number of posts that have this attribute. I’m going to write two helper functions for this then I’ll return back to the sizeof call. Here’s a helper function for finding the number of results that have the specified meta_key and meta_value that we have for this type of post. Notice that I’m using $wpdb to make a direct database call and that I’m specifically using prepare to make sure I do it safely. function get_headline_results() : array { global $wpdb; return $wpdb->get_results( // phpcs:ignore $wpdb->prepare( ” SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s “, ‘article_attribute’, ‘headline’ ), ARRAY_A ); } Notice that it returns all of the results (not just the number) because this value will be passed into another function momentarily. At this point, we could stop and simply look at the content that’s returned from the query but if we’re just concerned with the post post type, then we’ll need to account for that. Here’s one way to do it: function filter_posts_from_pages( array $results ) : array { $post_ids = array(); foreach ( $results as $result) { if ( ‘post’ === get_post_type( $result[‘post_type’] ) ) { $post_ids[] = $result[‘post_id’]; } } return $post_ids; } With that, we can return this value back to the count function

Continue reading