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

How to add an admin notice upon post save/update

The reason this doesn’t work is because there is a redirection happening after the save_post action. One way you can acheive want you want is by implementing a quick work around using query vars. Here is a sample class to demonstrate: class My_Awesome_Plugin { public function __construct(){ add_action( ‘save_post’, array( $this, ‘save_post’ ) ); add_action( … Read more

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