links
How can I get a different image size, if all I have is the link?
I decided to use this, which is based on @AndresYanez’s answer: function get_image_id_by_link($link) { global $wpdb; $link = preg_replace(‘/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i’, ”, $link); return $wpdb->get_var(“SELECT ID FROM {$wpdb->posts} WHERE BINARY guid=’$link'”); } This is much more succinct (since it doesn’t jump through the hoops of first removing the extension and then adding it back in), and is … Read more
how to grab first link in post… and of course call it
Two possibilities: Use the the_content-filter, or just call it in your template. You can just throw the plugin in your folder, or add one (or both) function(s) in your themes functions.php file. The filter triggers only for the post format link, while the template tag can be used more universal – in the loop. As … Read more
Can’t add a class to links in the visual editor since WP 3.1?
The link window was completely redesigned in 3.1 to make it easier to link to other posts in your blog. The “title” and “class” attributes were removed from this window, probably because the UI team thought they were not used as often?
Add delete, approve, spam Links to Comments
Per default wp_list_comments() calls the class Walker_Comment. Its method start_el() calls edit_comment_link() and here we find a filter for your question: It is called ‘edit_comment_link’ and it passes two variables, the link text and the comment ID, which we can use. The URLs to mark a comment as spam or to delete it are: wp-admin/comment.php?c=1&action=cdc&dt=spam … Read more
How to set all external links to a certain domain to “nofollow”?
Assuming you are targetting links in post content, I’d say something like that : add_filter( ‘the_content’, ‘wpse_254317_nofollow’ ); /** * Add rel nofollow according to a predefined domain * to links in content * @param $content * @link http://stackoverflow.com/a/4809181/1930236 * @return mixed */ function wpse_254317_nofollow( $content ) { $my_folder = “https://google.com”; preg_match_all( ‘~<a.*>~isU’, $content, $matches … Read more
Is there an easy way to create a links index page?
I think the WordPress bookmarks feature would work grand here. Here’s how I got this to work (generically). Go to Links->Link Categories and add all the letters of the alphabet as categories Create a new link, add a description and notes, and assign it to a specific alphabetical category. Create a page template (as shown … Read more
Why is there /index.php/ in all my links? How do I remove it?
After browsing all my dashboard, the solution turned out to be simple: Navigate to: Dashboard -> settings -> permalinks For some reason “Custom structure” was activated. I simply had to choose “Post name” instead. Now all my links look as they should.
I want to remove the links from the term list returned by get_the_term_list
You could use get_the_terms() and wp_sprintf_l(): function wpse_52878_term_list( $args = array() ) { $default = array ( ‘id’ => get_the_ID(), ‘taxonomy’ => ‘post_tag’, ‘before’ => ”, ‘after’ => ”, ); $options = array_merge( $default, $args ); $terms = get_the_terms( $options[‘id’], $options[‘taxonomy’] ); $list = array(); foreach ( $terms as $term ) { $list[] = $term->name; … Read more
Navigation link to specific user page
While you could possibly add a filter to walker_nav_menu_start_el and have your callback function alter/recreate the menu item according to your needs, I would say the best and easiest solution is to implement you own menu walker, and supply that to wp_nav_menu. This should help get you started: class WPSE_90204_Walker extends Walker_Nav_Menu { function start_el( … Read more