Permalink Short code showing unnecessary link text inside the loop

ob_get_flush doesn’t do what you think it does. You’re assuming that it only ends the output buffer and returns its contents, which is incorrect, it also flushes the output buffer to the browser. So this: return ob_get_flush(); Is the same as this: $content = ob_get_clean(); echo $content; return $content; Use ob_get_clean(); instead, which erases the … Read more

How can I check if a post with a particular slug or title exists?

You can use get_page_by_title() or get_page_by_path(). By default, both return a page’s WP_Post object, from which you can extract data. If the page doesn’t exist, they’ll return null. You can also use them on post types other than the built-in page. // By slug. $slug = ‘sample-page’; $page_by_slug = get_page_by_path( $slug ); // By title. … Read more

How can I create a shortcode to show the number of posts of actual day?

I tried some codes, and I think finally works after several tries: function ts_day_f() { $posts= get_posts(array( ‘numberposts’ => -1, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘date_query’ => array( ‘column’ => ‘post_date’, ‘after’ => ‘today’, ‘before’ => ‘tomorrow – 1 second’, ) )); if ( is_user_logged_in()) { //return count($posts); $c = count($posts); … Read more