WordPress Random post (last 3 days posts)

You can use this code for show last 3 days post. Best of luck… $args = array( ‘post_status’ => ‘publish’, ‘type’ => ‘news’, ‘posts_per_page’ => 2, ‘order’ => ‘rand’, ‘date_query’ => array( array( ‘after’ => ‘3 days ago’ ) ) );

Override Blog pages show at most with get_posts

In your code example, you’re mixing two things. With get_posts() you’ll get an array of posts, which you can use in a custom loop. $args1 = array( ‘post_type’ => ‘wpcp-events’ ‘numberposts’ => -1, ); $events = get_posts($args1); if ( $events ) { foreach ( $events as $post ) { setup_postdata( $post ); // make Loop … Read more

get_posts returns all posts

You are not using correctly the tax_queryargument. This argument takes array of tax query arguments arrays, to allow for complex queries with multiple taxonomies. You can learn more in the WP_Query documentation This is the correct way: $malls_args = array( “post_type” => “mall”, “tax_query” => array( array( “taxonomy” => “shop”, “field” => “name”, “terms” => … Read more

Not able to get random post

// Get a single random post from fetched posts $post = $news[rand(0, 4)]; setup_postdata($post); echo the_title(); echo the_intro(); // <- Custom function to retrieve custom field

Hide gravity forms

Try this; <?php $user = wp_get_current_user(); if ( count_user_posts( $user->ID ) >= 1 ) { // echo your text snippet } else { // echo your form } ?> 1) wp_get_current_user() returns the WP_User object which includes many properties for that user. 2) Since we only want the ID of the current user, we assign … Read more

Don’t submit post if post title exists

Here’s a sample code to get you started – basically it intercepts the creation of a new post by the user-submitted posts plugin(well at least it tries to, but in general there shouldn’t be any other posts created during that request). If a post with that name already exists, we add the content as a … Read more

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