Post count by meta_key meta_value [closed]

// retrieve all meta_values with key ‘state’ from database $state_posts = $wpdb->get_results(” SELECT meta_value FROM “. $wpdb->prefix.”postmeta WHERE meta_key = ‘state’ ORDER BY meta_value ASC”, ARRAY_A ); // define counting array $state_count = array(); // iterate through meta_values, count the occurence of each state foreach ( $state_posts as $state_post ) { if ( isset ( … Read more

Get single image from custom fields made with WCK custom fields creator

Here is the code that worked. I had to get rid of the foreach loop and reference the array directly: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $productimgs = get_post_meta( $post->ID, ‘productimg’, true ); $image_color = $productimgs[0][‘product-image-color’]; $image_bw = $productimgs[0][‘product-image-bw’]; $imgclr = wp_get_attachment_image_src( $image_color, ‘grid-large’ ); $imgbw = wp_get_attachment_image_src( $image_bw, … Read more

unlink() doesn’t delete the uploaded file

I figured it out! the problem is the path is not right! Thanks to this post : Alow users to delete uploaded images inside backend? this function below helped : function url_to_path_test($url){ $url=str_replace(rtrim(get_site_url(),”https://wordpress.stackexchange.com/”).”https://wordpress.stackexchange.com/”, ABSPATH, $url); return $url; } So in my code if you change the remove previous image like this it will work : … Read more

Search result page – display values from the result’s metaboxes

You just need to get the data using get_post_meta(). <h1><a href=”https://wordpress.stackexchange.com/questions/185685/<?php echo get_permalink()?>”><?php the_title(); ?></a></h1> <span class=”description”> <?php echo get_post_meta( get_the_ID(), ‘mobile_adv_service_desc’, true ); ?> </span> This Plugin stores your values as WordPress metadata. So to retrieve the values in the frontend, you can use the built in WordPress functions for that.

Taxonomy related query not working

The final code I used was: <?php $slides_category = get_field(‘slider_category’); $args = array( ‘post_type’ => ‘slides_post_type’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => array( $slides_category ), ), ), ); $slides_loop = new WP_Query( $args ); if( $slides_loop->have_posts() ): while( $slides_loop->have_posts() ): $slides_loop->the_post(); ?> // Post content goes here <?php endwhile; … Read more

ACF: Hide a div or template section when a custom field (in a field group) is empty

Hope this help how to figure out your request <?php $werdegang = ‘werdegang’; // werdegang parent group $station1 = ‘jahr_station_1’; // ‘ child group 1 $station2 = ‘jahr_station_2’; // ‘child group 2 $station3 = ‘jahr_station_3’; // ‘child group 3 $station1Jahr=”jahr1″; $station2Jahr=”jahr2″; $station3Jahr=”jahr3″; $station1Title=”jahr1_Title”; $station1Text=”jahr1_Text”; $station2Title=”jahr2_Title”; $station2Text=”jahr2_Text”; $station3Title=”jahr3_Title”; $station3Text=”jahr3_Text”; ?> <?php if( (!empty($station1Title) && !empty($station1Text)) && … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)