Custom Field in Featured image for A particular post

Note that there are additional input arguments available for the admin_post_thumbnail_html filter callback, namely $post->ID and $thumbnail_id: /** * Filters the admin post thumbnail HTML markup to return. * * @since 2.9.0 * @since 3.5.0 Added the `$post_id` parameter. * @since 4.6.0 Added the `$thumbnail_id` parameter. * * @param string $content Admin post thumbnail HTML … Read more

Encryption of WordPress Posts

As far as I know what you ask is not really possible with WordPress (or any plain PHP app) alone. It is same dilemma as with database credentials in WP – if FTP is hacked then hacker gets database login/password from wp-config.php. It is impossible to protect those because WordPress (or any other PHP app … Read more

Delete the original big size image after upload and leave only 3 images crunched by media gallery

How about this: add_filter( ‘wp_generate_attachment_metadata’, ‘delete_fullsize_image’ ); function delete_fullsize_image( $metadata ) { $upload_dir = wp_upload_dir(); $full_image_path = trailingslashit( $upload_dir[‘basedir’] ) . $metadata[‘file’]; $deleted = unlink( $full_image_path ); return $metadata; } Not 100% sure everything will work ok without the main image, but it does the trick. You wont be able to regenerate the thumbnails / … Read more

Sort posts by popularity/page views

The WP Postviews plugin is one of the most used to record post views. Then you can sort by amount by; <?php if (function_exists(‘get_most_viewed’)): ?> <ul> <?php get_most_viewed(); ?> </ul> <?php endif; ?> Or pass in the variables to the URL: http://example.com/?v_sortby=views&amp;v_orderby=desc Or even run a custom query that sorts by the post_meta value.

Display the latest post from a category in a page

You can make use of WP_Query to call the lastest post from the category and display it. Have a look at the category parameters. By default, WP_Query uses post as the post type and orders post by post date, so we can exclude that from the query. If you need something else, you can just … Read more

Skipping first 3 posts in wp query

For skipping the post just use offset parameter in wp_query. To display latest three post : <?php $latestpost = new WP_Query(‘order=asc&orderby=meta_value&meta_key=date&posts_per_page=3’); //Here add loop to display posts like while($latestpost->have_posts()) : $latestpost->the_post(); the_title(); the_content(); endwhile; wp_reset_query(); //After that skip three posts using offset $latestpost = new WP_Query(‘order=asc&orderby=meta_value&meta_key=date&posts_per_page=6&offset=3&paged=’ . $paged); the_title(); the_content(); endwhile; wp_reset_query(); ?> That’s it

Search by Hyphen

One approach is to modify the exclusion prefix through the wp_query_search_exclusion_prefix filter that’s supported in WP 4.7+. See ticket #38099. Here’s an example how we can change it from – to e.g. !: add_filter( ‘wp_query_search_exclusion_prefix’, function( $prefix ) { return ‘!’; // adjust to your needs (default is -) } ); where we would use … Read more

using wp_update_post on save_post

The reason it’s going to be infinite is that every time you save the post, it’s calling change_year…which then calls wp_update_post … which fires the save_post filter. After some review and research, I’m thinking that you should probably avoid the save_post filter. Try using this filter: http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data It gives you really what you want. Here’s … Read more

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