Forum Replies Created
-
AuthorPosts
-
cosmocanuckMemberThanks, I figured it out! I’d set up my metabox file in the correct place (within the theme, not as a plugin) but I hadn’t even added code to it. And once I added a proper PHP header and specified my custom post type name:
Title: Adaptive Snow Sports
Post Type: adaptiveetc…
And added some Piklist fields…
They show up perfectly.
I think I expected my custom post type to automatically contain the usual post elements, but of course one wouldn’t necessarily want that.
Thanks again. Piklist rocks!
Adam
cosmocanuckMemberACK!!! I see what my original mistake was.
I had a “$” before my reference to the Piklist variable, which was incorrect!
It’s right there in my first post:
<?php echo 'ID = ' . $resortData [$rs_ID][0]; ?>Should have been…
<?php echo 'ID = ' . $resortData [rs_ID][0]; ?>I fixed that… and it worked fine.
I should have known to take an even closer look when my “same method as the others” approach didn’t work.
Somewhat vindicated that nobody else noticed it either though! 8^)
But sorry to take up time with something that just needed more attention to my (broken) syntax.
Thanks Markus and Kevin!
Adam
cosmocanuckMemberIt worked, but I had to refer to my variable in the array style, i.e. though I call it “$sliderNumber”, I had to reference it as “$sliderNumber[0]” in the echo statement:
<?php $resortData = get_post_custom($post->ID); ?> <?php $sliderNumber = get_post_meta(get_the_ID(), 'rs_ID', false); ?> <?php if ($sliderNumber[0] > '') { echo get_new_royalslider($sliderNumber[0]); } ?>But it does work! And now my client can just enter in a single digit into one of my custom fields, instead of pasting in some arcane code to his post, to display the sliders he’ll be creating with the “Royal Slider” plugin. It works perfectly… hooray! And thanks to you both.
cosmocanuckMemberThanks guys, I will try that approach. But I have to ask: why does the following kind of code, which I have been successfully using to display tons of Piklist metadata for posts, not work for that one variable but DOES work for the rest?
<h3>Mountain Terrain</h3> <p><strong>Total Trails:</strong> <?php if ($resortData [total_trails][0]) { echo $resortData [total_trails][0]; } else {echo '0';} ?> </p>I have dozens of custom fields that I'm displaying with variations on the above. Before any of it, I have:
<?php $resortData = get_post_custom($post->ID); ?>;This latest request for metadata display is constructed the same way, but is failing, and I don't see what's different:
<?php $resortData = get_post_custom($post->ID); ?> <?php echo '<p>The slider ID for this listing is ' . $resortData [$royalSlider_ID][0] . ' and the average snowfall in inches is ' . $resortData [average_snowfall_in][0] . '.</p>'; ?>The second variable shows the value I expect, the first one returns nothing.
At any rate, I will try the above, clearly more robust method, for that particular bit of data – but I will leave the rest of my code alone, as it is working for me!
Thanks so much,
adam
cosmocanuckMemberThat’s super awesome, thank you! I’ll check out the plugins too.
September 28, 2013 at 12:11 am in reply to: Fatal error and lost checkboxes after switching themes? #1146
cosmocanuckMemberSorry Steve, it was my own bonehead mistake! I was using woefully out-of-date version of that “resortinfo.php” file, from my pre-Piklist attempt to display metadata. Naturally it didn’t work, it had different variables and no get_post_meta statement.
Sorry to waste your time by not having done due diligence first. But thanks for at least giving me a nudge in the right direction!
cosmocanuckMemberI’m sorry, I was looking at the wrong plugin! I’m at version 0.7.2 of PikList. That’s the version it says you get when you download from that URL. Do you have a preview / beta version? it does say b5 at the end so I assume so… that’s probably the problem…?
cosmocanuckMemberAh! I’m using version 1.0.6. It’s the latest version… you seem to be using an older one? Not sure why that would be the case…
cosmocanuckMemberHmm, I assume there’s some other factor causing Preston’s bug? ‘Cause my single checkbox works fine. My code is:
piklist('field', array(
'type' => 'checkbox',
'field' => 'snow_cross',
'label' => 'Snow Cross?',
'attributes' => array(
'class' => 'text'
)
,'choices' => array(
'Yes' => 'Yes'
)
));
And the checked / unchecked boxes are staying that way….
cosmocanuckMemberSorry, clearly a case of RTFD (read the fine documentation). I assume a single option in the choices array will do it, and I can check for the field’s value in the theme’s appropriate template file.
cosmocanuckMemberThanks Steve! I’ll check it out. Unfortunately many if not most of the options I want are “yes or no” selections which I’m implementing with a single checkbox each. Worried that none of these could be searched on… but as you say, I’ll give it a try and see how it goes. Fingers crossed!
-
AuthorPosts