Hide sidebar if post_type is in array

This is more php, but you can use in_array(). Just check if the current post type is in array in $hide_sidebar. You can do the following $hide_sidebar = array(‘example1’, ‘example2’, ‘example3’); //hide sidebar on these post types if ( in_array( get_post_type(), $hide_sidebar ) ) { // Do something if the post type is in array … Read more

How to display line breaked meta values in table?

You can use explode() or preg_split(), like this: $i = 0; foreach( $namesArray as $key => $name ) { $arr = explode( ‘ -‘, $name, 2 ); //$arr = preg_split( ‘/\s+\-/’, $name, 2 ); $name2 = isset( $arr[0] ) ? trim( $arr[0] ) : ”; $role_name = isset( $arr[1] ) ? trim( $arr[1] ) : … Read more

Save meta box values as an array to wp_postmeta

In PHP, there is no need to use the square brackets that are required in an HTML form name to indicate an array, such as you get when using checkboxes. In other words, this in HTML: <label><input type=”checkbox” name=”brand[]” value=”1″> Brand 1</label> <label><input type=”checkbox” name=”brand[]” value=”2″> Brand 2</label> <label><input type=”checkbox” name=”brand[]” value=”3″> Brand 3</label> Will … Read more

How to decipher the following array

You’re looking at a serialized representation of the array Array( ’75’, ’68’ ). Serialization is the process by which PHP stores a data object as a string, much like the manner in which JSON is a string representation of a Javascript object. PHP data structures may be converted into a serialized format via PHP’s serialize(), … Read more

WordPress i18n in Array throws Error

This is a PHP issue, not specific to WordPress. PHP does not allow you to declare a property as an expression. It should be a literal. So you can not call a function inside a property declararion. (see Invalid property declarations in http://php.net/manual/en/language.oop5.properties.php) The solution is to create a getter method and use it instead. … Read more

Customizer Settings in Arrays

The get_theme_mod() function works the following: It fetches the get_theme_mods() function under the hood. This returns the following data $theme_slug = get_option( ‘stylesheet’ ); get_option( “theme_mods_{$theme_slug}” ); So in case you upgrade, write an upgrade function specific for that version of your plugin or theme, that uses one of the following, where the name is … Read more

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