How to check an array of $curauth fields?

Try <?php if ( !empty( array ( $curauth->facebook ) ) || !empty ( array ( $curauth->linkedin ) ) || !empty( array( $curauth->twitter ) ) ) { echo ‘echo me if any $curauth info exists’; } ?> Note: This can be all on fewer lines, I’ve just put in additional line-breaks to make it all fit … Read more

How to use shortcode attribute in separate function

To be able to use a variable that is essentially being created within the shortcode function, you’ll need to store it somewhere and then retrieve the value. WordPress does use global variables internally to store and carry across values, but I wouldn’t advise you do the same though. Read about the options API here. Pretty … Read more

How to validate register settings array

Personally I’d do it the same way, since it seems to be the only point where you can examine user input and validate it. Also, heavily borrowing from code sample in this excellent article: function wpPartValidate_settings( $input ) { if ( check_admin_referer( ‘wpPart_nonce_field’, ‘wpPart_nonce_verify_adm’ ) ) { // Create our array for storing the validated … Read more

Dropdown category filter

I don’t see where your posts are pulling from, just the category list, but you are most likely missing the post_count variable where you have your query args to retrieve the posts. post_count=-1 will return all, but it defaults to 10 (or whatever is set in your settings) if you do not specifically say otherwise.

How do I output a database option that is an array into a get_posts array?

You could use wp_parse_id_list() to sanitize your comma seperated list of post IDs. It’s defined as: function wp_parse_id_list( $list ) { if ( !is_array($list) ) $list = preg_split(‘/[\s,]+/’, $list); return array_unique(array_map(‘absint’, $list)); } where we can see that it returns unique array values as well. Note that absint() is defined in core as abs( intval() … Read more

How to add day number and initial to my post graph?

I would go like this: A. Use the Unix timestamp as array key. $comment_counts[$date->format(‘U’)] = $query->post_count; B. Loop with key included. foreach( $comment_counts as $count_key => $count ) : Then you obtain the day number and the initial of the day from the key: // “d” means with leading zero, use “j” in place of … Read more

Generate an array of parent/child page IDs, based on parent page name

OK, so what we want to achieve is to write a function that will take a title of a page and return the array containing its ID and IDs of its children. So here’s the code: function get_page_and_its_children_ids_by_title( $page_title ) { $result = array(); $page = get_page_by_title( $page_title ); // find page with given title … Read more