Utilising posts with various post types & categories?

Post Types I would certainly register ‘News’, ‘Events’ and ‘Opportunities’ as custom post types, while maybe keeping ‘Articles’ as the default ‘Post’ post type. (See the Codex on custom post types). This would, among other things, allow you to register/de-register metaboxes for specific post types where appropriate. Also, as requested, ‘News’, ‘Events’, etc will have … Read more

Writing a view count with w3 total cache

This won’t work if page caching is enabled, I would recommend creating an ajax request which calls this function instead. e.g. add_action( “wp_ajax_nopriv_view_count”, ‘view_count’ ); add_action( “wp_ajax_view_count”, ‘view_count’ ); function view_count(){ update_post_meta($_GET[‘id’], ‘view_count’, $count++); } (then create an ajax call in JS which passes through the page id to this counting function) Ajax shouldn’t be … Read more

Restrict access to post if it is currently being edited

The warning notice gets dispatched by the function wp_check_post_lock. The following redirects the user back to the post listing screen if someone else is editing it. add_action( ‘load-post.php’, ‘redirect_locked_post_wpse_95718’ ); function redirect_locked_post_wpse_95718() { if( isset($_GET[‘post’] ) && wp_check_post_lock( $_GET[‘post’] ) ) { global $typenow; $goto = ( ‘post’ == $typenow ) ? ” : “?post_type=$typenow”; … Read more

How do I use inline SVG in WordPress

According to this post, if you put all the svg block in one line, it will be rendered. This should work: <svg xmlns=”http://www.w3.org/2000/svg” version=”1.1″ height=”190″> <polygon points=”100,10 40,180 190,60 10,60 160,180″ style=”fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;”> </svg>

Convert IPTC keywords to blog post tags

WordPres has a function that extract IPTC info from images, that function is wp_read_image_metadata. That function is only available on admin side and, according with the codex, it doesn’t extract IPTC keywords. But you can use iptcparse from PHP at your own to extract IPTC keywords and set them as post tags. In your question, … Read more

Hiding posts from non logged in users

Fiddling with user roles would probably be the most robust solution, however a quick and dirty approach would be to set post meta-data to mark posts that should be hidden, then add a meta-query to post queries by using a pre_get_posts hook in order to restrict results to non-hidden posts for non-logged-in users. The following … Read more

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