Tag Info

New answers tagged

0

Unable to test this at the moment, but try something along these lines. Search all posts for your Post Name (Special title), grabbing the ID's, then utilize post__not_in to exclude those IDs in get_posts. function getAllPostIdsTest(){ global $wpdb; $excluded_posts = $wpdb->get_results("SELECT id FROM " . $wpdb->posts . " WHERE `post_title` ...


0

You must use add_rewrite_rule() method, or add_rewrite_endpoint() in order to flush rewrite rules, and links you must generate with add_query_arg() method for ugly urls, for tiny u must simple concatenate with permalink


0

Thanks to @Howdy_McGee. He gave me the hint to look after serialized meta queries. With this code I get the desired result. $args = array( 'posts_per_page' => -1, 'orderby' => 'post_date', 'order' => 'DESC', 'post_status' => 'publish', 'meta_query' => array( array( 'key' ...


1

As your data is currently structured, you can't use SQL to do that (well, not in a performant way, at least). You have two options: Fetch ALL posts and loop through them in memory looking for the correct post meta, or Store the meta values separately. Between the two, I advise the latter. WordPress permits you to store multiple rows of the same post meta ...


1

I don't believe you can accurately compare values for a Serialized Array, which happens whenever you pass an array to update_post_meta, you need to get the entire value during your loop using get_post_meta( $post->ID, 'enterprise_on_page', 1 ) If you need to specify queries based on these values it's best to save them out separately. View this ...


0

Thank you for answering!. I was looking for a more complete solution. I figured it out. echo '<div class="row profiles">'; $terms = get_terms("clinical-programs"); if ( !empty( $terms ) && !is_wp_error( $terms ) ){ foreach ( $terms as $term ) { //View faculty member by clinical programs ...


0

list all the PAGES that are assigned to particular page(s). I'm assuming you mean "particular term(s)." which would be in your clinical-programs taxonomy. You'll have to do a bit of coding - you need to start a new WP_Query and structure your query as such: $taxPages = new WP_Query( array( 'post_type' => 'YOUR_POSTTYPE_HERE', 'clinical-programs' ...


0

SELECT * FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) LEFT JOIN ...


0

post_parent returns only the child pages of the page whose ID is given as the value. post_parent (int) - use page id to return only child pages. Set to 0 to return only top-level entries To get just a specific page, rather use page_id or pagename or post__in (in conjunction with post_type=page. I would suggest that you rather make use of get_pages ...


0

Thanks for your ideas. I ended up creating two different queries for the carousel re-ordering using offset: The first query displays the third most recent post: $args = array( 'posts_per_page' => 1, 'offset'=> 2 ); $thirdPost = get_posts( $args ); and then spit the required fields into the first carousel slide div. The next query grabs the first ...


1

Reordering the way you want is really pretty trivial. Proof of concept: $p = array(1,2,3); var_dump($p); array_push($p,array_shift($p)); var_dump($p); With the WordPress code: $p = get_posts('posts_per_page=3'); array_push($p,array_shift($p)); var_dump($p); To make it more interesting, you can do the same with a filter. Since get_posts() uses ...


0

I don't think WordPress offers any way to order posts as you like. It has ASC and DESC order to list posts. But you can create a custom field for each carousel post to define carousel item orders. Let's say if you created custom field named carousel-order and add numerical value to each post. Then you can add custom order like this. get_posts( array( ...



Top 50 recent answers are included