$url = 'https://legacy.cafebonappetit.com/api/2/cafes?cafe=687';
$response = wp_remote_get( esc_url_raw( $url ) );
$slices = json_decode( wp_remote_retrieve_body( $response ), true );
if ($slices) {
foreach ($slices as $slice) {
echo '<p>Menu Name: '.$slice['cafes']['687']['name'].'</p><br/>';
echo '<p>Weekly menu status: '.$slice['cafes']['687']['days']['status'].'</p><br/>';
// insert more logic here
}
}
echo "<pre>";var_dump($slices);echo "</pre>";
I can get it to display all using var_dump, but I can’t get individual element to display.
Any help would be appreciated?
Thanks,
Aaron
]]>My questions are:
The simplified database schema.
I want to be able to manage the Image Categories, Images, Image Comments and the Canned Comments in the backend.
Again, the questions I have are:
I am more than happy to clarify the question if there is any need to.
Thanks a lot gang.
]]>I need to retrieve a value from a multidimensional array.
The array can be found here:
https://pastebin.com/MJmRGEuF
What I need to do is to retrieve the “amount” based upon the users role.
i.e gold_membership = 50 etc…
Sorry but I have no idea where to begin.
]]>array( array (
"key1" => "value1", "key2" => "value2", "key3" => "value3"
) )
However, this serializes the array into a string, which I don’t want because I’m using this data with a plugin.
When I use update_post_meta with the same array, it works perfectly, however I’ll only be able to submit one set of values this way.
Is there any possible way to use add_post_meta without serializing the array?
]]>Here’s the jist of it
$ip = $_SERVER['REMOTE_ADDR'];
$id = $_POST['post_id'];
$voter_ips = get_post_meta($id, 'voter_ips');
array_push($voter_ips, $ip);
update_post_meta($id, 'voter_ips', $voter_ips);
When I do this the first entry is saved correctly and from then on I get an unwanted multi-dimensional kind of value such as this;
Array ( [0] => Array ( [0] => 123.2.29.197 ) ) Array ( [0] => Array ( [0] => 123.2.29.197 ) [1] => 123.2.29.197 )
I’ve tried dozens of ways of fixing this but I’m stumped. Do I need to be doing some serializing and unserializing here, I had a go of that but with no success so far.
Any help greatly appreciated as always
]]><form action=”options.php” post=”post”>
I get the options by
<?php settings_fields( 'theme_styles' ); ?>
<?php $options = get_option( 'theme_styles_options' ); ?>
I have a field
<input type="text" id="theme_styles_options[option_name]" name="theme_styles_options[option_name]" class="regular-text" value="<?php esc_attr_e( $options[option_name] ); ?> />
I would like to be able to have this field multiple times but under different arrays e.g.
array(
'first_array' => array(
'option_name' => 'value1'
)
'second_array' => array(
'option_name' => 'value2'
)
)
I know at the moment it my current code saves as
array(
'option_name' => 'value1'
)
How to I set my field to send the value to the options.php page to be saved as a multidimensional array? Also, if someone knows how to save it, how to I retrieve it from the field in the database?
Many Thanks
]]>———
<?php comments_popup_link(‘ No Comments’, ‘ 1 Comment<?php mdv_comment_plugger(‘, Last By’,1,’ ‘); ?>’, ‘ % Comments<?php mdv_comment_plugger(‘, Last By’,1,’ ‘); ?>’); ?>
———
So basically, I want to include the function mdv_comment_plugger, but only if there are 1 or more comments. So I’m including them within the comments_popup_link so that they’ll only appear in those circumstances. Does that make sense?
Thanks,
.z
]]><?php
$subpages = $wpdb->get_results("
SELECT post_title
FROM $wpdb->posts
INNER JOIN $wpdb->page2cat
ON $wpdb->page2cat.page_id = $wpdb->posts.ID
WHERE $wpdb->page2cat.pagecat_id = 2
");
?>
When I view the results of $subpages with print_r()
I get this:
Array
(
[0] => stdClass Object
(
[post_title] => Test 1
)
[1] => stdClass Object
(
[post_title] => Test 2
)
[2] => stdClass Object
(
[post_title] => Test 3
)
)
I find it difficult working with this array, because I can’t access the values easy. There is a stdClass Object in each entry of the array. Does anyone know of a way to not get the stdClass Object
or how to easily work with such an array?
For example, it would be easy if I could retrieve the value like $subpages[0]
or $subpages['post_title']
as a one dimensional array.