Related posts queries
Related posts queries
Related posts queries
Assuming your CPT is ‘videos’ you’d use: // Build the query $args = array( ‘post_type’ => ‘videos’, ‘posts_per_page’ => ‘4’, ‘cat’ => $cat_id );
// Get the category ID from url $catsearched = $_GET[‘product_cat’]; //printf($catsearched); $earth_radius = 6371; // Get products of category with in range distance $querystrShop = $wpdb->prepare(” SELECT productid AS post_id,(%d * ACOS(COS(RADIANS(%s)) * COS(RADIANS(phiz_geo_location.latitude)) * COS(RADIANS(phiz_geo_location.longitude) – RADIANS(%s)) + SIN(RADIANS(%s)) * SIN(RADIANS(phiz_geo_location.latitude)))) AS distance, phiz_postmeta.meta_value FROM phiz_geo_location JOIN phiz_term_relationships ON phiz_geo_location.productid = phiz_term_relationships.object_id LEFT JOIN … Read more
There is actually a way to get posts from all multisite sub-sites. I do it with my “Multisite Media Display” plugin here https://wordpress.org/plugins/multisite-media-display/ . I use it to display all media items from my multisite to ensure that any submissions meet the site requirements. Works great. I have a similar plugin for posts, but it … Read more
Let’s see if this works. I can’t really test this, but there are some things to update in your code: function set_activation_value(){ // Sets Field Defaults $option = get_option(‘ews_index_option_name’); // get_option returns FALSE if it doesn’t exist, so we check that here. if ( $option === FALSE ) { $args = array ( ‘public’ => … Read more
The problem is here: switch_to_blog($subsite_id); $blog_posts = get_posts(); restore_current_blog(); foreach( $blog_posts as $post ) { setup_postdata( $post ); get_template_part( ‘theme-partials/post-templates/loop-content/masonry’ ); } Your code fetches a number of posts, but then you switch back to the original blog! So now post number 5 means something completely different than it did before. You need to stay … Read more
Get all posts by many custom post types
You can use get_page_by_path() to get a Page’s WP_Post object using its slug (ie, its path), and then use that object to then get the array of child page IDs using get_children(). // First we’ll create the list of posts (pages) to exclude. $exclude = array(); $parent_page_obj = get_page_by_path( ‘abc’ ); if ( ! empty( … Read more
How do i POST to WordPress rest API from the same domain?
The request to the server is in this phrase: value=”?orderby=date&order=DESC”>. That is a WP_query string. You would use a date_query with the after argument to construct a query that will return posts which were published after a certain date. Note that the string will be different every time, since it depends on the current date … Read more