Tag Info

New answers tagged

0

I couldn't understand your question. If you are adding payment form to a post which is not public, then how any one can see the payment form. If you want to say that you already have some posts which are not published yet, then pass the id of the post that you want to publish via the payment form and after the payment completed chance the status of the post ...


0

I think this can ve achieved using hidden fields if the single post form Add a field like this in your form <form> YOUR CODE GOES HERE ------------------- <input type="hidden" name="mypostid" value="<?php get_the_id(); ?>" /> </form> And the page where this form is posting the data you can get the data for the field mypostid ...


0

The custom query to get custom post type posts filtered by 2 different terms from 2 different taxonomies will be: $args = array( 'post_type' => 'listing', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'job_listing_region', 'field' => 'slug', 'terms' => ...


2

You can simply just use the post__in parameter inside your query arguments or inside your pre_get_posts action EXAMPLE (Adjust as necessary. Code requires at least PHP 5.4+ due to short array syntax ([])) $args = [ 'post__in' => range( 10, 15 ), ]; $q = get_posts( $args ); var_dump( $q );


0

The category parameters does not work with custom taxonomies. You need to use a tax_query instead. In your current code, replace (which is in any case also wrongly used, category_name takes the slug, not name) 'category_name' => $category->name with 'post_type' => 'case-studies', 'tax_query' => array( array( 'taxonomy' => $tax ...


0

This code display all posts of all categories of location taxonomy for custom post type testaismgallery. $args = array( 'number' => $number, 'hide_empty' => $hide_empty, 'include' => $ids ); $custom_categories = get_terms( 'location', $args ); foreach ( $custom_categories as $catterm){ $arg = ...


-1

this code will display the post from all taxonomy in wordpress: $args = array( 'type' => 'post', 'child_of' => 0, 'parent' => '', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' ...


0

use here set type method: add_action('init','engineCreateRecurringSchedule'); add_action('engineRecurringCronJob','engineDaysToGoUpdate'); function engineDaysToGoUpdate(){ // Arguments to get published posts with 'engine' post type. $engineDaysToGoArgs = get_posts( array ( 'post_status' => 'publish' 'posts_per_page' => -1, ...


4

You can use 'posts_orderby' filter to change the SQL performed. Note that: using get_posts() you need to set 'suppress_filters' argument of false for the filter to be performed if you don't explicitly set 'post_status' you'll get only published posts (so no much to order) Code sample: $filter = function() { return 'post_status ASC'; }; ...


3

In all probability you are using a custom taxonomy, and not the build-in category taxonomy. If this is the case, then the category parameters won't work. You will need a tax_query to query posts from a specific term. (Remember, get_posts uses WP_Query, so you can pass any parameter from WP_Query to get_posts) $args = [ 'post_type' => 'product', ...


-1

<ul> <?php $args = array( 'posts_per_page' => 5, 'offset'=> 1, 'category' => 1 ); $myposts = get_posts( $args ); foreach ( $myposts as $post ) : setup_postdata( $post ); ?> <li> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </li> <?php ...


0

I am not 100% sure if this is what you want but maybe this code snippet helps you out? I tried it in a template and it did show (in my case) the content of 1 CPT from a specific category so actualy should this code snippet work. <?php global $post; $args = array( 'posts_per_page' => 1, 'category' => 7, 'orderby' ...



Top 50 recent answers are included