Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

I have developed functionality which is check duplicate value for specific post meta value exist or not on update post. when user update data and if find any record then give a error message in admin dashboard(see attached screenshot). you can use below code according your requirement. class Check_duplicate_entry { public function __construct(){ ...


0

There's not really any trick, you need to check all the values. You can save a little space though, by omitting the != '', which is redundant: if ( get_theme_mod( 'myplugin_h2_color' ) || get_theme_mod( 'myplugin_h3_color' ) || get_theme_mod( 'myplugin_p_color' ) || get_theme_mod( 'myplugin_p_size' ) ) { However, it's possible to save ...


0

I figured it out... $meta_value = get_user_meta( $atts['owner'], $meta_key, true ); $store_numbers = array(); foreach ($meta_value as $store_number) { $store_numbers[] = 'shop'.$store_number; } $usernames = $store_numbers;


1

Your call to get_user_by() has a small hiccup in it. It needs to be login rather than user_login // Search these Usernames $usernames = array('user1', 'user2'); // Fetch the User IDs $prof_ids = array(); foreach ($usernames as $prof_id) { $user = get_user_by('login', $prof_id); $prof_ids[] = $user->ID; } // WP_User_Query arguments $args = ...


0

get_posts() isn't modifying the main query. The problem is that you're overwriting the global $post variable in your foreach loop. I guess if you're in a template then you're in the same scope as the global variable and don't need to specify global $post; for this to happen (as you would if you were inside a function). Rename $post in your loop and the issue ...


0

So here is my attempt at it...though I don't really have a good place to test it on my end, but I think it should work. (Fingers Crossed) <?php // First Page of Pagination - https://codex.wordpress.org/Function_Reference/is_paged if(!is_paged()){ $first_page = true; $query_args = array( 'posts_per_page' => '11', ); } else { ...


0

The answer was that I had dequeued the woocommerce style sheets and fonts, adding the CSS back in made the tick marks appear .added:after { font-family: WooCommerce; content: '\e017'; margin-left: .53em; vertical-align: bottom; display: inline-block; }


0

The answer was pretty simple, sorry for bothering you) if( has_term( 'taxonomy slug', 'taxonomy' ) ) { continue; }


0

Filter should modify the given value and return it. It should not print anything. But your foreach loop does exactly opposite - it prints its output and doesn’t append anything to result. So when you use it to append its result to the content, it prints its result and doesn’t return anything - so nothing gets appended. One way to fix it is to use buffering:...


0

are you asking how to exclude posts that contain certain text? (mod please move this to a comment, I do not have the reputation)


1

Depending of what you are exactly trying to achieve accessing the first element of the $posts array may work for you. No need for the foreach loop. echo '<img src="'.$posts[0]['img']['url'].'">';


0

Finally i had create a taxonomy with name manufacturers and an attribute with the same name. This may caused a confict (i didn't find out more!). So i create an attribute with name brands and i use this for my custom query.


0

For the value 0 in add_post_meta the view count is not updating. Try the line add_post_meta($postID, $count_key, '1'); instead of line add_post_meta($postID, $count_key, '0');.


0

Add this after $args $categories = get_terms('category', $args); //get all categories $count = count($categories ); //count categories if ( $count > 0 ){ //Check if you got some categories foreach ( $categories as $category ) { $args['cat'] = $category->term_id; //get the id of each category and add it as a parameter $loop_our_work = new WP_Query( $...


0

If you wish to get posts between two dates, then use the before and after parameters in the date_query parameter, $query_string = array( 'post_type' => 'post', 'date_query' => array( 'column' => 'post_date', 'after' => '2012-04-01', 'before' => '2012-04-30' ), 'tax_query' => array( array( 'taxonomy' =&...


2

If I understand it properly, You can use the post__in parameter to query for specific posts where the post ID is in that parameter: $ids = [ 1, 2, 3, 4, 5 ]; $query = new WP_Query( array( 'post__in' => $ids, // ... other args, if any. ) ); // Then loop through the posts. if ( $query->have_posts() ) { while ( $query->have_posts() ) : $...


0

I believe you can fetch that data using setup_postdata() which lets you access all the data relating to a post and use it with standard template tags (in your case, the_post_thumbnail). There is a great tutorial here: https://wpshout.com/setup_postdata-template-tags-need-custom-wp_post-arrays-crave/ Important to note that you first have to setup the global ...


0

An alternative solution using WP_Query would be: <?php $args = array( 'post_type' => 'post' ); $the_query = new WP_Query( $args ); $totalpost = $the_query->found_posts; ?>


Top 50 recent answers are included