Prevent Authors from viewing each others Posts

If you want to prevent a user with the “Author” role to view other users’ posts in the overview screen (they won’t be able to view the details anyway), you can add an extra filter on the author: add_action( ‘load-edit.php’, ‘wpse14230_load_edit’ ); function wpse14230_load_edit() { add_action( ‘request’, ‘wpse14230_request’ ); } function wpse14230_request( $query_vars ) { … Read more

Get first post from wp_query

If you poke through WP_Query the set of queried posts is saved into posts property and current post gets assigned to post one (each time loop iterates). So you could do $connected->posts[0] if you need to just fetch that, but it might be more convenient to do $connected->the_post(); then $connected->post if you need to skip … Read more

get_children() Not Working with orderby Parameter

Are you sure you need this specific function? Documentation (both Codex and inline) is verrry confusing. And it supposedly fetches things like attachments, which probably aren’t relevant for navigation… Try this: get_posts( array( ‘post_type’ => ‘page’, ‘post_parent’ => $parent->ID, ‘orderby’ => ‘menu_order’ ) );

Count how many posts in category

If I remember right count of posts in category is stored persistently in category object. So use get_category() or variation of it and fetch the number out of object. Example code (not tested): $category = get_category($id); $count = $category->category_count; if( $count > $something ) { // stuff }

Change label of title field for posts in the backend

function change_post_titles() { global $post, $title, $action, $current_screen; $title = “foo<br>bar”; $title = str_replace(‘<br>’, ‘ ‘, $title); } add_action(‘admin_head’, ‘change_post_titles’); Use this this will give the result you want. Please check it let me know for any doubts.

Custom Post Types, slug, archive and SEO plugins

I don’t know what content you want to insert in your archive page, but you can always use the file “archive-friends.php” as you can see in the Template Hierarchy to loop your “friends” post type. Then, to customize the SEO, I recommend you the plugin WordPress SEO by Yoast because it has a strong compatibility … Read more

Connection lost. Saving has been disabled… (Updating Posts/Pages)

That message is a result of your server throwing a 503 error and the WordPress Heartbeat API catching that error. See https://core.trac.wordpress.org/ticket/25660 for the background on the fix that WordPress introduced to save offline edits. Things to check on your computer are if WAMP is actually running when you’re getting this message (check the status … Read more

What’s $object->filter for?

The $post->filter contains the context under which the contents of the post have been filtered. Context could be something like “display” indicating the post is meant to be displayed on the page. This is done by the sanitization functions, to indicate under what context the post data was sanitized. Different contexts get different types of … Read more

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