How to Display Network Post Count?

Made a couple of tweaks to brasofilo’s example as we were getting hit with memory execution issues; one of which may be related to a possible switch_to_blog memory leak that has been impacting sites doing a lot of switch_to_blog calls (we would typically run around ~1000 or so when loading this dashboard widget.) Even with … Read more

How to receive HTTP POST in WP?

Easy! You have a couple of options to do so. The easiest one, but less safe, is to create a brand new PHP file in the root folder of WordPress. Let’s say we will call it get_post.php and add WordPress functionality to it. Like so: <?php require_once(‘wp-load.php’); // add wordpress functionality $post = $_POST; if … Read more

Confirmation box when submitting post for review

A useful fast way is to use JavaScript in combination with an Ajax action that outputs the box. Create a small plugin. Create a folder inside plugins directory, naming it ‘SubmitReviewConf’. In this folder create a PHP file named SubmitReviewConf.php. In this file, put this code: <?php /** * Plugin Name: Submit for Review Confirmation … Read more

Add tag to post api wordpress

You’ll find an index of a good chunk of the WordPress API here on codex. The function you want is wp_set_post_tags(), but follow the links from that page to related functions. Edit: this should remove a tag from a post, per comment below // $post is your post object, e.g. from: global $post; // $target … Read more

Removing filter dropdown in posts table (in this case Yoast SEO)

These additional dropdowns are added via the restrict_manage_posts action hook. This means the dropdown output isn’t filterable, but you can remove the hooked action from Yoast SEO. The filter dropdown is added by the posts_filter_dropdown() method in the WPSEO_Metabox class. It’s added in the setup_page_analysis() method of the same class, which is hooked into admin_init … Read more

get all posts ID from a category

The thing to remember about get_posts is that is uses a WP_Query object internally. get_posts source: <?php /** * Retrieve list of latest posts or posts matching criteria. * * The defaults are as follows: * ‘numberposts’ – Default is 5. Total number of posts to retrieve. * ‘offset’ – Default is 0. See {@link … Read more

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

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