Use Filename for Alt and Title Tags

The alt tag already takes the filename but if for some reason you need to replace hyphens with spaces and include a duplicate title of the alt tag you can do something like: function wpse_120228_seomadness($html, $id, $caption, $title, $align, $url, $size, $alt) { $alttitle = str_replace(‘-‘, ‘ ‘, $alt); $img = get_image_tag($id, $alttitle, $alttitle, $align, … Read more

lazy load comments wordpress on click

Templates like the comments template need to be loaded on the page, as it relies on some global variables to know what post to load the comments for, so just pulling in the template with Javascript won’t work like that. You’ll need to create an AJAX wrapper that sets up the post data before getting … Read more

show limited tags in an article

Your code with changes: <?php $post_id = get_the_ID(); $queried_post = get_post($post_id); $user_info = get_userdata($post->post_author); // <– or: $user_info = get_the_author_meta(‘ID’) $first = $user_info->first_name; // what if it is empty or contains forbidden characters? $last = $user_info->last_name; // as obove wp_set_post_tags( $post_id, $first, true ); // <– tag slug, used in the code below // — … Read more

How to use the php if statement [closed]

You may do it this way using open/close bracket {} <?php if ( 1==2) { ?> <textarea> “Add multiple lines of text here and watch the scrollbars grow.”> </textarea> <?php } ?> In general rules you need to enclose all the if else statement using php tag and the html outside it. You may also … Read more

Config apple-app-site-association file with wordpress

OP moved this question to StackOverflow: https://stackoverflow.com/a/45399792/6471228 Answer via Alex Bauer: Since the apple-app-site-association file is not a WordPress file, you have to configure the content type at the server level. This is different depending on environment (Apache vs. nginx, for example). This can be hard, if your host doesn’t allow access to low level … Read more

Seriously stuck with some custom meta box/plugin stuff

Here is a simple example that adds a meta box to all public post types: // All public post types $post_types = array_merge( array(‘page’ => ‘page’, ‘post’ => ‘post’), get_post_types(array(‘_builtin’ => FALSE)), ); // Add meta box for each post type foreach ($post_types as $post_type) { add_meta_box(‘id’, ‘title’, ‘callback’, $post_type); } WP Codex: get_post_types(), add_meta_box().