Get post ID from a link

I guess you’re not after the current post/page ID, but rather trying to find the ID for some url from your site. Then you should try out the handy url_to_postid() WordPress core function. It returns the post/page ID if it exists, else 0. Example: echo url_to_postid( ‘http://example.com/2014/11/14/hello-world’ ); // Outputs the post ID as 1 … Read more

Display related post by tag name of current post

As stated in a comment, your get_posts parameters are wrong. There is no such parameter as term_id. You should make use tag which uses the tag slugs as a string or tag__in which uses the tag ids in an array This will work $posts = get_posts(‘numberposts=6&tag=’. $tags->slug); or this will work $posts = get_posts(‘numberposts=6&tag__in=’ . … Read more

Changing default WP-Site creation date

There is no blog creation date in WordPress. The first blog post is usually regarded as the blog creation date when you create copyright footer notes for a blog. This is not very reliable though. There are a few thing that happens by default when WordPress is first installed, the most important being a user … Read more

Transition from Draft to Scheduled Post with wp_update_post

Try adding edit_date => true to your bmt_post array, like so: $bmt_post = array( ‘ID’ => $post_id, ‘post_title’ => wp_strip_all_tags( $title ), ‘post_content’ => $information, ‘post_status’ => $post_status, ‘post_category’ => array( $cat_ids ), ‘post_date’ => $post_date, ‘edit_date’ => true ); If you look at the function wp_update_post found here: scheduling posts with wp_update_post you can … Read more

Sort Custom Post Type by Category ID then Post Name

To order taxonomy terms by ID, you have to set the orderby argument: $tax_terms = get_terms( ‘portfolio’, array( ‘orderby’ => ‘id’ ) ); See the get_terms Codex page for a complete list of arguments for the function. To order the posts by name (slug), set orderby to ‘name’ in your query arguments: $args = array( … Read more