Tag Info

New answers tagged

5

You can use get_the_title() to return the current post title in the loop.


1

Okay anyone wanting to achieve this, the code works. Just save the values in the custom field without quotes. e.g. red, car <?php $list = get_field( "main_attributes" ); $array = explode(',', $list); $args = array( 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'style_atrributes', ...


0

Please add ";" after $i = $i++ and see if that fixes your issue foreach ($socialIcons as $icon) { $i = $i++; $wp_customize->add_setting( 'pxk_href_' . $icon['name'], // use this in twig file call to theme_mod array( 'default' => '', 'transport' => 'postMessage', 'priority' => $i ) );


4

You are using an incorrect check here. is_singular() returns true when a post is from the specified post type or post types or the default post types when none is specified. You cannot target specific single posts with is_singular() You have to use is_single to target a specific post if ( is_single( 'post-a' ) { // Do something for post-a } elseif ( ...


3

I think you have over complicated your parameter for "is_singular", or is "custom-post-type" an actual CPT of yours? Try: if ( is_singular( 'custom-post-type' ) ) { // Foo } else if ( is_singular( 'another-custom-post-type' ) ) { // Bar }


0

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.


3

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(), and back again using ...


0

After unserializing the result is: Array ( [0] => 75 [1] => 68 ) You can find the format of PHP serialized array here: Serialized PHP string a:2 is object array here 's':<i> is the string where i is the length of string


0

It seems like the your multiple values were simply serialized by PHP's serialize() function. You can unserialize it with unserialize().



Top 50 recent answers are included