Restrict custom post type to only site administrator role

register_post_type() accepts a parameter capabilities in its arguments. See get_post_type_capabilities() for possible values. From the comments: By default, seven keys are accepted as part of the capabilities array: edit_post, read_post, and delete_post are meta capabilities, which are then generally mapped to corresponding primitive capabilities depending on the context, which would be the post being edited/read/deleted … Read more

Get the Current Page Number

When WordPress is using pagination like this, there’s a query variable $paged that it keys on. So page 1 is $paged=1 and page 15 is $paged=15. You can get the value of this variable with the following code: $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; Getting the total number of pages is a bit trickier. … Read more

Should we trust the post globals?

There is a sad truth: you can never ever be sure that some code will not break your code, and there is nothing you can do to prevent that. Especially in WordPress, where everything is global. That said, yes, global $post is one of the most used global var, so using special care for it … Read more

Print Current Post Index number within Loop

Actually I want to assign ID’s as per post index ! Here’s your code that I modified. <?php global $wp_query; $posts = $woo_options[‘woo_latest_entries’]; query_posts(‘post_type=post&category_name=company’); if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++; $index = $wp_query->current_post + 1; ?> <div id=”my_post_<?php echo $index; ?>”> <!– Post Content Goes Here –> </div> <?php … Read more

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