View post with specific category id and name which I selected in the backend (drop-down option)

Try this code. <?php $cat_id = get_theme_mod(‘cat_choose’, $defaults); ?> <p><?php echo get_cat_name( $cat_id ); ?></p> <hr> <?php $args = array( ‘post_type’ => ‘post’ , ‘orderby’ => ‘date’ , ‘order’ => ‘DESC’ , ‘cat’ => $cat_id, ‘posts_per_page’ => -1, ); $cat_posts = new WP_query($args); if ($cat_posts->have_posts()) : while ($cat_posts->have_posts()) : $cat_posts->the_post(); ?> <div> <div> <h1><?php the_title(); … Read more

How to use orderby on meta_value when using Pods custom database table storage

As with any custom tables in your database, you can override the SQL that WP_Query ends up using. For this use case, I’d suggest not using WP_Query’s arguments and building your own function to do this instead as it could simplify the logic and complexity. <?php add_filter( ‘posts_clauses’, ‘my_custom_wp_query_posts_clauses’, 10, 2 ); /** * Custom … Read more

wp_mail sending only once inside foreach loop

Sometimes the mail port can get clogged up, so I usually add a brief sleep(10) in the for-loop. The 10 seconds is arbitrary, but it works for my purposes. foreach($entries as $key=>$entry){ $email = array( ‘[email protected]’ ); $subject = “Documents Requested”; $headers = array(‘Content-Type: text/html; charset=UTF-8’); $message = getDMVemailMessage($entries[$key][‘id’]); $sent = sendDMVNotifyEmail($email, $subject, $message, $headers); … Read more

How to get files from loop for zip

As the files are within the same WP installation (not a remote), you don’t need to download the file using get_file_contents(), try to add the file using its absolute path of the attachment. if(isset($_POST[‘download’])){ $tmpFile = tempnam(‘/tmp’, ”); $zip = new ZipArchive(); $zip->open($tmpFile, ZipArchive::CREATE); foreach( $list_posts as $list_item ) : if ( $list_item->post_type == ‘crb_photo’ … Read more

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