Array of user ids to list of user names
get_userdata() – http://codex.wordpress.org/Function_Reference/get_userdata – returns an object. You need to provide the correct return value: echo $name->nicename;
get_userdata() – http://codex.wordpress.org/Function_Reference/get_userdata – returns an object. You need to provide the correct return value: echo $name->nicename;
Widgets echo data. Take a look at the widget method of some of the default widgets, like this one. You can’t save that data to an array without writing your own function to process the widgets and using output buffering where the widgets themselves echo content. And sidebars/sidebar-widgets are complicated. That is not an easy … Read more
Modify your first code chunk thusly: $names = array(); $CatID = array( 1, 5, 3,); foreach ( $CatID as $ID ) { $names[] = get_the_category_by_ID( $ID ); // uncomment the next line to get the name tied to the ID // $names[$ID] = get_the_category_by_ID( $ID ); } var_dump( $names ); See PHP’s array() reference for … Read more
I think you messed up a bit. I’m assuming you’re using the ACF plugin because you used the_field(). Have you tried only the_field(‘titdesc’); if you’re in the WordPress loop? Those functions already query values stored in your postmeta table. I’m assuming you have a field called titdesc since you’re trying to read it using the_field(‘titdesc’). … Read more
You can use get_author_posts_url() or get_the_author_meta(): $values = get_field( ‘editor’ ); if ( $values ) { $editors = array(); foreach ( $values as $value ) { $link = get_author_posts_url( $value[‘ID’] ); //get the url $nicename = $value[‘user_nicename’]; $editors[] = sprintf( ‘<a href=”https://wordpress.stackexchange.com/questions/106854/%s”>%s</a>’, $link, $nicename ); //create a link for each author } echo ‘Edited by: … Read more
$level must be passed as an integer, not as a string. The problem is with the plugin code: if (count($labels) !== $level && $labels !== ”) { echo ‘Category Chain Select Plugin</br>Error :: Number of labels don\’t match number of levels’; The !== operator requires a match on type as well as value. Had the … Read more
Are you getting the color and price variables from the URL? If so, you need to use $_GET not $_POST, and you may want to escape or validate your value. Also I suggest not defining them as variables, because if there is no value for either of those taxonomies, you don’t need the tax queries … Read more
offset parameter of get_comments() function accepts integer values for more information visit this codex page. so your get_comments function call should be as following. $numbers = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5); $random_key = array_rand($numbers, 1); $comments = get_comments(array(‘orderby’ => ‘comment_karma’, ‘number’ => 20, ‘status’ => … Read more
$meta = get_post_meta(get_the_ID(), ‘_podPressMedia’, true); $meta = maybe_unserialize($meta); if (is_array($meta) && count($meta) > 0) foreach($meta as $item){ //do something… } Please, do not use unserialize/serialize with php data stored structures there is native maybe_serialize/maybe_unserialize. Retriving single value from postmeta table also doesn’t require get_post_custom, all you need to do to use get_post_meta whish will return … Read more
Make use of the functions wordpress offers to determine paths and URLs – see Determining Plugin and Content Directories. For example use: get_template_directory to Retrieves the absolute path to the directory of the current theme, without the trailing slash. or get_stylesheet_directory to Retrieve stylesheet directory Path for the current theme/child theme. You find more information … Read more