You should be able to use this:
if (isset($meta_field['category'])) {
// Get all post data for that category
$post_data = get_posts_by_category($meta_field['category'], 0,
$post_limit);
} else {
$args = array(
'numberposts' => $post_limit,
'offset'=> 1,
'category' => '9,3',
);
$post_data = get_posts($args);
}
Related Posts:
- Custom HTML structure in wp_list_categories
- Custom category code not showing all posts
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- How to show only subcategories in parent category not parent category?
- Use get() method to grab all categories and output inside another method
- Listing titles and custom fields of entries within subcategories
- WordPress custom taxonomy
- Remove Custom Post Category In WordPress Slug Using .Htaccess
- How do I edit the terms output args or array data?
- Create category after theme setup and modify the default one
- How to replace hard-coded list of custom taxonomy terms based on custom field query [closed]
- Get category id for a custom category and display it in a class
- Saving category as insert post
- Get category name of current post (CPT UI)
- Show the terms of the hierarchical taxonomy
- My Own layout in WooCommerce pages [closed]
- Woocommerce – remove product from category
- Get category name from custom loop and echo it once
- Differences when using the the_time and the_date functions
- Exclude posts from homepage having a specified tag
- Display all categories including sub categories
- Why is this Ajax not working?
- How do I access the media settings
- How do themes render caption texts in extended markup (e.g. “wp-caption” paragraphs)
- Changing the template hierarchy
- using add_action for a header hook that has an additional parameter
- get_the_terms – only top level
- custom shortcode will not display the wrapped content
- Weird problem happening with custom taxonmy when creating/updating posts
- Can’t load WP function into external function
- Get Custom URL For Custom Taxonomy
- Displaying theme options in css
- get_terms orderby numeric
- max_input_vars: how many am I using?
- Rename “Portfolio” slug?
- How to show a dynamic_sidebar if main content content’s height is > a set amount?
- Category Thumbnail Display – How to display ONLY the main Category
- Sum custom field values of particular taxonomy
- Where do posts get the sidebar from?
- Set WordPress Default Template
- Adding country tags automatically
- write custom woocommerce templates and forms
- Implement toggle switch for theme options in settings API
- hover image appears below placeholder instead of overlayed
- combine Code 1 with Code 2
- Query all posts of a custom taxonomy term
- Using a `Template Parts` folder instead of an `Includes` folder in a Custom WordPress Theme
- get current product name in functions.php
- Using a variable in is_page(array())
- Trigger popup in a php if/else statement
- Anyway to output the registration form like the login form with wp_login_form()?
- How do I get current page ID in WordPress customizer file?
- Customizer: Output default value in Customizer CSS
- How to load a template-part based on a url wildcard?
- get post based on category chosen in drop down – The ajax method
- WordPress does not load page.php, return 404.php
- How to use transient in this code for related post?
- How can i upload images in an admin page?
- Where to edit the template that is generating the code for dynamic_sidebar left-sidebar in the Understrap theme? [closed]
- get_term_link() returns incorrect url
- Multiple WordPress Menus that will only display all pages
- Creating a related post section based on similar categories
- Set the checkbox as checked by default at options page
- Swapping wp_dropdown_categories function with wp_category_checklist
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Add child pages of parent to navbar PHP
- How can I create a list of page titles from custom meta values?
- Load a page into a div with Ajax
- Create a hierarchical taxonomy list in WordPress
- Randomly Assign an Image’s Alt Text Based on Data From Post
- Custom theme: Alternatives to long list of ‘include’ in functions.php
- Theme Options Page – User Updates Logo
- Converting HTML Template to WordPress Theme
- Proper syntax or method for keeping url in modified isotope / category links
- How to use my style.css file outside of wordpress subdomain?
- Apply different Class for each element in a foreach()
- How to show part of the_content?
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Wp-login appears White Screen, Error: Cannot modify header information
- Filter Select results based on selection
- How to remove the cufon script from Dzonia Lite theme [closed]
- get_the_tags() not iterating through for/while loop, but will with foreach
- Hide categories that are not used in the post type
- What is an equivalent of single_cat_title for getting the slug of the category?
- Issue adding sub category programmatically
- How do I add custom bulk actions to multiple custom post types?
- Add_action not working in required file of functions.php
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- How to exclude category ID from Looper in WordPress
- Add a specific part of current category page url to shortcode
- how do I get a specific post from a post with a subcategory in WP
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- what is the best practice to add new field to an api route
- WP grandchild categories in nested ul li
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Can’t access variable outside for loop
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- add custom link to wordpress media gallery modal
- How to show single category archive