How to get all posts related to particular category name?

Just use WP_Query() to generate your custom query, using the category parameters. Assuming you know (or know how to get) the ID of the specific category, as $catid: <?php $category_query_args = array( ‘cat’ => $catid ); $category_query = new WP_Query( $category_query_args ); ?> Note: you could also pass the category slug to the query, via … Read more

Custom Single Post By Category

Make your single.php the following: <?php $post = $wp_query->post; if ( in_category( ‘work’ ) ) { include( TEMPLATEPATH.’/single-work-cat.php’ ); } else { include( TEMPLATEPATH.’/single-generic.php’ ); } ?> and make single-work-cat.php the template you wish to show for single work category posts, and single-generic.php the one you wish to show in all other cases. For more … Read more

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

How to moderate posts

This is a partial answer, because as I mentioned in my comment I’m not sure why your code is requiring two ‘really bad words’ at the moment. It’s also an untested attempt. I’ll deal with your first question: how to send a user back to the posts page and display a suitable error message, rather … Read more

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