How to publish a post with empty title and empty content?

If the post content, title and excerpt are empty WordPress will prevent the insertion of the post. You can trick WordPress by first filtering the input array so empty values are set to something else, and then later resetting these values back to empty strings. This will bypass the standard check. add_filter(‘pre_post_title’, ‘wpse28021_mask_empty’); add_filter(‘pre_post_content’, ‘wpse28021_mask_empty’); … Read more

How to remove Nextpage tag inside posts text depending of utm_campaign

You can use the_post hook to remove <!–nextpage–>. In this case: add_action( ‘the_post’, ‘campaign_remove_nextpage’, 99); function campaign_remove_nextpage ( $post ) { if ( ($_GET[‘utm_campaign’]== ‘nonextpagecampaign’) && (false !== strpos( $post->post_content, ‘<!–nextpage–>’ )) ) { // Reset the global $pages: $GLOBALS[‘pages’] = [ $post->post_content ]; // Reset the global $numpages: $GLOBALS[‘numpages’] = 0; // Reset the … Read more

order posts by date like craigslist

You may notice that I did more or less exactly this for Matt’s site: http://ma.tt. Every set of posts is grouped by the day. The basic principle is to keep track of your day in the loop, then print the date and related stuff only when it changes. Take a basic Loop: if ( have_posts() … Read more

Is there a way to disable the sticky posts feature?

You can’t turn it off, because it’s hard-coded into the submit metabox for the post post type, you can however hide the sticky checkbox and update the sticky array to unstick any currently stuck posts. Hide the sticky checkbox Add additional CSS to the post and post-new pages add_action( ‘admin_print_styles’, ‘hide_sticky_option’ ); function hide_sticky_option() { … Read more

Exclude drafts in all() view of edit.php

The show_in_admin_all_list parameter in the register_post_status() function, determines if a given post status is included in the All post table view. Probably the shortest version is: add_action( ‘init’, function() use ( &$wp_post_statuses ) { $wp_post_statuses[‘draft’]->show_in_admin_all_list = false; }, 1 ); but let’s avoid modifying the globals directly like this and override the default draft status … Read more

Modifying admin sidebar contents to show pending posts indicator

@ign Replace the line of code you posted with the following.. foreach( $menu as $menu_key => $menu_data ) : if( ‘edit.php’ != $menu_data[2] ) continue; $menu[$menu_key][0] .= ” <span class=”update-plugins count-$pending_count”><span class=”plugin-count”>” . number_format_i18n($pending_count) . ‘</span></span>’; endforeach; ..that should avoid the need to know the specific key.. (let me know if any problems).. Hope that … Read more

Modify ‘Read more’ link adding a new class

What (exactly) happens When calling the_content() inside your template, you are able to call it without any parameters. This means, that the function already has the defaults of null for both arguments: The “more” link text and the boolean switch that allows you to strip teaser content before the “more” link text. The the_content() function … Read more

How do I detach images from posts?

If you view the Media Library in the list mode: /wp-admin/upload.php?mode=list then you will see the Attach/Detach links for each attachment. Each attachment can only be attached to a single parent through the post_parent field in the wp_posst table. Deleting an image from the post editor will not change the post_parent field to 0. Making … Read more

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