Limit Post Creation Count by Author or Role

I have a site that offers non-paying members up to 5 posts using this: function author_post_count($user_id, $post_type = array(‘YOUR_CUSTOM_POST_TYPE_NAME_HERE’)) { $args = array( ‘post_type’ => $post_type, ‘author’ => $user_id, ‘posts_per_page’ => -1 ); $query = new WP_Query($args); return $query->found_posts; } Then I use: if ( author_post_count(get_current_user_id()) >5) { SHOW RESTRICTION NOTICE CODE HERE FOR USERS … Read more

Redirecting wordpress search query to archive page

Simply make an HTML form in Elementor on the archive page where you want to search. Code: <form class=”zohaib-search-form” role=”search” action=”/courses” method=”get”> <input placeholder=”Search..” name=”s” type=”search”> <button type=”submit”><i class=”fas fa-search”></i></button> **Note:** name property of input should be ‘s’ because the search query is looking for key ‘s’ to get and run it. Replace the action … Read more

How to add a custom class attribute into code wrapper? [duplicate]

To add your custom class to the old posts at once, you can do this via “the_content” filter and using preg_replace or preg_replace_callback function to do a REGEX replacement. A working Example: add_filter( ‘the_content’, function( $content ){ // Don’t do anything if we’re not in a single post if(! is_singular()){ return $content; } $customClass=”custom-class”; return … Read more