get_posts – check if custom field has content?

Try this: $args2 = array ( ‘numberposts’ => -1, ‘post_type’ => ‘houses’ ); $custom_posts2 = get_posts($args2); foreach ( $custom_posts2 as $custom_post2 ) { // check here if custom post type opjects custom field “sz_website” has content $sz_website = get_post_meta( $custom_post2->ID, ‘sz_website’, true ); if ( !empty ($sz_website)) { echo ‘<div class=”wpcf7-list-item-field”>’ . $sz_website . ‘</div>’; … Read more

Custom Category widget

Original Code Sample Removed, updated based on new answer: Honestly this doesn’t change too much, other than makes it a bit more succinct, and I’ll explain the major points of what I’ve done. You reuse this code sample a lot: <li class=”cat-item”><a href=”https://wordpress.stackexchange.com/questions/295287/<?php echo get_category_link($cat->term_id); ?>”><?php echo $cat->name; ?></a><span class=”post_count”><?php echo ” ($cat_posts->found_posts+$cat_probs->found_posts)”; ?></span> Inline, … Read more

Fill the exclude array() in get_posts()

After three days of struggling and posting a question here I managed to find an answer. Yeh I know… To my defense I can say that it’s my first WP project. I did it this way: $exclude = get_excluded_parents(); $parents = get_posts( array( ‘post_type’ => ‘jhk_story’, ‘orderby’ => ‘ID’, ‘order’ => ‘ASC’, ‘numberposts’ => -1, … Read more

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