how to get random post id by using post type

As far I understood you want to set the value of $id randomly from adzones post type post ids. I hope this helps you- $args = array( ‘orderby’ => ‘rand’, ‘posts_per_page’ => ‘1’, ‘post_type’ => ‘adzones’ ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $id = get_the_ID(); echo do_shortcode(“[pro_ad_display_adzone id=”.$id.”]”); … Read more

Possible to alternate between two loops

You need two queries for this. Let’s say the ID of the featured category is 5. Then you set up two queries retrieving 3 posts each: $query1 = new WP_Query( array( ‘cat’ => ‘5’, ‘posts_per_page’ => 3 ) ); $query2 = new WP_Query( array( ‘cat’ => ‘-5’, ‘posts_per_page’ => 3 ) ); Now you have … Read more

Shortcodes on my website stops working after theme update [closed]

most likely your [download_ebook_lead_form ret_url=””] shortcode was defined in functions.php in your theme parent folder, and during update the file was somehow replaced with new one. If you have backup of previous version of your theme check its functions.php and look for add_shortcode( ‘download_ebook_lead_form’…). If you find it there just copy entire function to functions.php … Read more

Only show a Post once in 10 visits

function lsmwp_post_limter($ids, $in, $count) { $i = rand(1,$count); if ($i <= $in) { return($ids); } else return false; } function lsmWpfilter($posts){ $result = []; foreach($posts as $post){ $res = lsmwp_post_limter($post[‘postId’], $post[‘in’], $post[‘count’]); if ($res){ $result[] = $res; } } print_r($result); return $result; } $exluded_posts = array( array(‘postId’ => 28741 , ‘in’ => 2, ‘count’ => … Read more

How to include my own css in post

The easiest way in most recent themes is to use the Custom CSS from the Theme Customizer. If it is enabled in your theme, you can access it through: Appearance -> Customize. If it’s not enabled, you should first refer to your theme’s documentation. Is it a free or bought theme?

Display Posts on Custom Page

If News is a category of posts, then: First, find out the category ID, login to wp-admin, go Posts->Categories, mouse over the ‘News’ category, and cat id should be shown under the left corner of the browser (for chrome this works, not sure about other browsers). Add the following code into your function.php function my_news_category( … Read more

Posts loop displaying the same post data

Try using WP_Query instead. So the code would be like: <?php $args = array( ‘posts_per_page’ => 5, ‘cat’ => 2, ‘offset’ => 0, ‘order’ => ‘date’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’ ); $post_query = new WP_Query($args); if($post_query->have_posts()) : while($post_query->have_posts()) : $post_query->the_post(); ?> <div><?php the_permalink(); ?></div> <div><?php the_title(); ?></div> <div><?php the_content(); ?></div> <?php endwhile; endif; … Read more