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

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

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

Website bookmarks as a custom post type

Here’s a clean way to accomplish what you need. Register custom post types (sans post_tags and categories) Register taxonomies specific to your bookmarks Create a post meta box for the bookmark options (sample included). You could add a nofollow checkbox option to the meta box. Save post meta Here’s the whole shabang. add_action(‘init’, ‘bookmark_post_type’); function … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)