Tag Info

Hot answers tagged

6

Prevent authors from publishing too short content: Here's one idea using a custom post status, for example short: /** * Register a custom 'short' post status * * @see http://wordpress.stackexchange.com/a/159044/26350 */ function wpse_short_post_status() { register_post_status( 'short', array( 'label' => _x( 'Short', ...


6

This question is going to get some opinion based answers, but well, I'll give it a try. There are a couple of reasons why someone might've told you that, it would be great to know the context also. Upto version 3.4 or 3.5, that function only worked when the parameter was a var, that might be one of the reasons why someone told you that. I, myself, don't ...


6

For starters let's dive into what is 5 really. It is the post's ID. But what is ID in turn? It is value in the MySQL table row which identifies the specific post record. Issues with using IDs So first there are some conceptual problems with it. It's not content. It's not something user creates, manipulates, or (most of the time) aware of. WP is (by design) ...


2

First of all I have to say that private posts already fit your needs, because logged in users with proper capability will see the posts in home page, archives, searches and so on. Proper capability is 'read_private_posts'. This cap is assigned by default to administrators and editors. So, your "member" users should have one of these 2 roles or maybe you ...


2

The correct way to register a taxonomy is to wait for the action registered_post_type, because that’s the only way to know that your post type actually exists. This action is fired when a post type was registered. Core post types are registered twice for reasons. You have to wait for the second call, because the rewrite object is not available earlier. If ...


2

Your code will never get to the is_page_template() if statement because is_page_template() can only be true when is_page() is also true. It also looks like you've got some muddled elseif syntax (I think that's what you want?) and some generally inefficient code that repeats a lot. I'd do this: <?php if( is_page_template('right-sidebar.php') ) { // ...


1

You can do this using a plugin. A couple of options are RSS Image Feed WP RSS Images


1

You can just simply create a custom query with WP_Query. You just need to make sure if you are using a custom taxonomy or the build-in category. For reference, see: Is There a Difference Between Taxonomies and Categories? Here is an example for custom taxonomies (this can also be used for build-in categories, just change 'taxonomy' => ...


1

I've realised what the issue was... some of my posts were generated (for development purposes) using bulk creator which appears to not create a complete post! When I create a post manually using the WP backend my code works fine, thanks for the suggestions anyway guys!


1

/** * Get the author post count for a tax query. * * @link http://wordpress.stackexchange.com/q/159160/1685 * * @param array $tax_query * @return int */ function wpse_159160_get_author_posts_by_tax( $tax_query ) { global $wpdb; $where = get_posts_by_author_sql( 'post', true, get_post()->post_author ); $tax_query = new ...


1

Don't change the Post ID. Wordpress uses serialized data, and id's have deep linking within the database.



Only top voted, non community-wiki answers of a minimum length are eligible