- This topic has 2 replies, 2 voices, and was last updated 3 years, 8 months ago by
jeanne.
-
AuthorPosts
-
-
May 22, 2018 at 3:23 am #8999
jeanneParticipantHi! I hope you can assist!
I have recently beccome webmaster of a site abandoned by the original developer. There were custom pages created that requires that images be uploaded in specified “Presenter” pages. The images do upload in the editor but it doesn’t display in the front end.
I have never worked with Piklist and also not sure if the php are coded correctly. I am not so good with php.
Piklist is running on it’s latest install 0.11.1 and WP has been updated. I found the php pages that correspond to the output and it is displayed like this(for the page url: http://mfm.co.za/presenter/test/) THIS IS THE ORIGINAL CODE FROM PREVIOUS DEVELOPER:
————————————-
<?php
/*
Title: Enter Details for Presenter Profile
Description: Custom Post Type that handles the Presenter Profile Information
Post Type: presenter
Context: normal
*/
$available_timeslots = array(
’01:00-04:00′,
’04:00-06:00′,
’06:00-10:00′,
’10:00-12:00′,
’12:00-14:00′,
’14:00-16:00′,
’16:00-19:00′,
’10:00-14:00′,
’17:00-19:00′,
’19:00-21:00′,
’17:00-21:00′,
’21:00-01:00′,
’19:00-22:00′,
’22:00-01:00′,
’14:00-17:00′
);piklist(‘field’, array(
‘type’ => ‘file’
,’field’ => ‘_thumbnail_id’
,’scope’ => ‘post_meta’
,’label’ => __(‘Profile Picture of Presenter’)
,’description’ => __(‘Images ideally sized at 120px X 120px’)
,’options’ => array(
‘modal_title’ => __(‘Add File(s)’,’piklist’)
,’button’ => __(‘Add Presenter Photo’,’piklist’)
)
));piklist(‘field’, array(
‘type’ => ‘textarea’
,’field’ => ‘presenter-blurb’
,’label’ => __(‘Presenter Short Write Up’)
,’description’ => __(‘A brief introduction to the Presenter’)
,’attributes’ => array(‘rows’ => 6)
,’columns’ => ’12’
));piklist(‘field’, array(
‘type’ => ‘text’
,’field’ => ‘twitter’
,’label’ => __(‘Twitter Username’)
,’description’ => __(‘Their @username’)
));piklist(‘field’, array(
‘type’ => ‘text’
,’field’ => ‘instagram’
,’label’ => __(‘Instagram Username’)
,’description’ => __(‘http://instragram/USERNAME’)
));piklist(‘field’, array(
‘type’ => ‘text’
,’field’ => ‘nameshow’
,’label’ => __(‘Name of the Show’)
,’columns’ => ’12’
));piklist(‘field’, array(
‘type’ => ‘checkbox’
,’field’ => ‘days’
,’label’ => __(‘Days the Show is on Air’)
,’description’ => __(‘Which days of the week is the show on air?’)
,’attributes’ => array(
‘class’ => ‘text’
)
,’choices’ => array(
‘monday’ => ‘Monday’
,’tuesday’ => ‘Tuesday’
,’wednesday’ => ‘Wednesday’
,’thursday’ => ‘Thursday’
,’friday’ => ‘Friday’
,’saturday’ => ‘Saturday’
,’sunday’ => ‘Sunday’
)
,’columns’ => ’12’
));piklist(‘field’, array(
‘type’ => ‘radio’
,’field’ => ‘showtime’
,’label’ => __(‘Timeslot of the Show’)
,’attributes’ => array(
‘class’ => ‘text’
)
,’choices’ => $available_timeslots
,’columns’ => ’12’
));piklist(‘field’, array(
‘type’ => ‘textarea’
,’field’ => ‘presenter-show-blurb’
,’label’ => __(‘About Their Show’)
,’description’ => __(‘A brief introduction to the Presenter\’s show’)
,’columns’ => ’12’));
piklist(‘field’, array(
‘type’ => ‘radio’
,’field’ => ‘secondshow’
,’label’ => __(‘Does the Presenter have a Second Show?’)
,’value’ => ‘no’
,’attributes’ => array(
‘class’ => ‘text’
)
,’choices’ => array(
‘yes’ => ‘Yes’
,’no’ => ‘No’
)
,’columns’ => ’12’
));piklist(‘field’, array(
‘type’ => ‘text’
,’field’ => ‘nameshow2′
,’label’ => __(‘Name of the Second Show’)
,’columns’ => ’12’
,’conditions’ => array(
array(
‘field’ => ‘secondshow’
,’value’ => ‘yes’
)
)
));piklist(‘field’, array(
‘type’ => ‘checkbox’
,’field’ => ‘days2′
,’label’ => __(‘Days the Second Show is on air’)
,’description’ => __(‘Which days of the week is the show on air?’)
,’attributes’ => array(
‘class’ => ‘text’
)
,’choices’ => array(
‘monday’ => ‘Monday’
,’tuesday’ => ‘Tuesday’
,’wednesday’ => ‘Wednesday’
,’thursday’ => ‘Thursday’
,’friday’ => ‘Friday’
,’saturday’ => ‘Saturday’
,’sunday’ => ‘Sunday’
)
,’columns’ => ’12’
,’conditions’ => array(
array(
‘field’ => ‘secondshow’
,’value’ => ‘yes’
)
)
));piklist(‘field’, array(
‘type’ => ‘radio’
,’field’ => ‘showtime2′
,’label’ => __(‘Timeslot of Second Show’)
,’attributes’ => array(
‘class’ => ‘text’
)
,’choices’ => $available_timeslots
,’columns’ => ’12’
,’conditions’ => array(
array(
‘field’ => ‘secondshow’
,’value’ => ‘yes’
)
)
));piklist(‘field’, array(
‘type’ => ‘textarea’
,’field’ => ‘presenter-show-blurb2′
,’label’ => __(‘About Second Show’)
,’description’ => __(‘A brief introduction to the Presenter\’s second show’)
,’columns’ => ’12’
,’conditions’ => array(
array(
‘field’ => ‘secondshow’
,’value’ => ‘yes’
)
)
));piklist(‘field’, array(
‘type’ => ‘textarea’
,’field’ => ‘soundcloud’
/*,’add_more’ => true*/
,’label’ => __(‘Embed Codes for Soundcloud Songs or Mixes’)
,’description’ => __(‘Paste the code in the box. Click on the [+] button to add another.’)
,’attributes’ => array(‘rows’ => 6)
,’columns’ => ’12’
));piklist(‘field’, array(
‘type’ => ‘file’
,’field’ => ‘my_upload_field’
,’scope’ => ‘post_meta’
,’label’ => ‘Media Uploader’
,’options’ => array(
‘modal_title’ => __(‘Add File(s)’,’piklist’)
,’button’ => __(‘Add Images’,’piklist’)
)
));piklist(‘field’, array(
‘type’ => ‘file’
,’field’ => ‘artist_album_img’
,’scope’ => ‘post_meta’
,’label’ => __(‘Artist and Album Cover Images’)
,’description’ => __(‘Images ideally sized at 160px X 160px’)
,’options’ => array(
‘modal_title’ => __(‘Add File(s)’,’piklist’)
,’button’ => __(‘Add Images’,’piklist’)
)
));piklist(‘field’, array(
‘type’ => ‘text’
,’field’ => ‘fav_artist_name’
,’label’ => __(‘Favourite Artist Name’)
,’columns’ => ’12’
));piklist(‘field’, array(
‘type’ => ‘text’
,’field’ => ‘fav_album_name’
,’label’ => __(‘Favourite Album’)
,’columns’ => ’12’
));piklist(‘field’, array(
‘type’ => ‘text’
,’field’ => ‘fav_album_artist’
,’label’ => __(‘Favourite Album (Artist or Band Name)’)
,’columns’ => ’12’
));?>
—————————————-
The accompanied code for this is:
—————————————–
<?php get_header(); ?><div id=”content”>
<?php
$image_id = get_post_thumbnail_id();
$cover = wp_get_attachment_image_src($image_id, ‘_thumbnail_id’);
$cover150 = str_replace(“.jpg”, “-150×150.jpg”, $cover[0]);$favourite_artist = get_post_meta($post->ID, ‘fav_artist_name’, true);
$favourite_album = get_post_meta($post->ID, ‘fav_album_name’, true);
$fav_album_artist = get_post_meta($post->ID, ‘fav_album_artist’, true);$days = get_post_meta($post->ID, ‘days’);
$secondshow = get_post_meta($post->ID, ‘secondshow’, true);
$days2 = get_post_meta($post->ID, ‘days2’);
$show_blurb = get_post_meta($post->ID, ‘presenter-show-blurb’, true);
$show_blurb2 = get_post_meta($post->ID, ‘presenter-show-blurb2’, true);
$soundcloud = get_post_meta($post->ID, ‘soundcloud’, true);
$twitter = get_post_meta($post->ID, ‘twitter’, true);
$instagram = get_post_meta($post->ID, ‘instagram’, true);
$username = get_post_meta($post->ID, ‘instagram’, true);$whichslot = get_post_meta($post->ID, ‘showtime’, true);
$whichslot2 = get_post_meta($post->ID, ‘showtime2’, true);$timeslots = array(‘1AM–4AM’, ‘4AM-6AM’, ‘6AM-10AM’, ’10AM-12PM’, ’12PM-2PM’, ‘2PM-4PM’, ‘4PM-7PM’, ’10AM-2PM’, ‘7PM-10PM’, ‘9PM-10PM’, ‘7PM-9PM’, ‘5PM-9PM’, ‘9PM-10PM’, ’10PM-1AM’, ‘2PM-5PM’);
?><div class=”title-head”><h1><?php the_title(); ?></h1></div>
<div class=”atsng-col clearfix”>
<div class=”presenter-info”><div class=”presenter-profile-img” style=”background-image: url(<?php echo $cover150;?>);”></div>
<div class=”presenter-bio”>
<p class=”name”><?php the_title(); ?></p><?php if (!empty($twitter)) {
echo ‘<p class=”twitter-username”>‘ . ‘@’ . $twitter . ‘</p>’;
}?><p class=”blurb”><?php echo get_post_meta($post->ID, ‘presenter-blurb’, true)?></p>
<ul class=”social-icons”>
<li class=”email-icon”>“>
<?php
if (!empty($instagram)) {
echo ‘<li class=”instagram-icon”>‘;}
if (!empty($twitter)) {
echo ‘<li class=”twitter-icon”>‘;}
?><?php /*
$limit = empty($instance[‘number’]) ? 9 : $instance[‘number’];
$size = empty($instance[‘size’]) ? ‘thumbnail’ : $instance[‘size’];
$target = empty($instance[‘target’]) ? ‘_self’ : $instance[‘target’];if ($username != ”) {
$media_array = $this->scrape_instagram($username, $limit);
if ( is_wp_error($media_array) ) {
echo $media_array->get_error_message();
} else {
// filter for images only?
if ( $images_only = apply_filters( ‘wpiw_images_only’, FALSE ) )
$media_array = array_filter( $media_array, array( $this, ‘images_only’ ) );?><ul class=”instagram-pics”><?php
foreach ($media_array as $item) {
echo ‘‘;
}
?><?php
}
} */ ?>
</div></div><!– end .presenter-info –>
<div class=”time-slots”>
<h4>TIMESLOTS</h4>-
<?php
- ‘ . $shortweek[$i] .
‘<div>
<p>’ . get_post_meta($post->ID, ‘nameshow’, true) . ‘</p>
<p>’ . $timeslots[$whichslot] . ‘</p>
</div> - ‘ . $shortweek[$i] . ‘<div class=”on-air”><p> </p><p> </p></div>
$i = 0;
$week = array(“monday”, “tuesday”, “wednesday”, “thursday”, “friday”, “saturday”, “sunday”);
$shortweek = array(“mon”, “tues”, “wed”, “thurs”, “fri”, “sat”, “sun”);while ($i <=6) {
if (in_array($week[$i],$days)) {
echo’‘;
}else { echo’
‘;
}
$i++;
}
?><?php
if ($secondshow == ‘yes’) {echo ‘<h4 style=”margin-top:140px;”>SECOND SHOW TIMESLOTS</h4>
- ‘;
- ‘;
echo $shortweek[$i];
echo ‘<div>’;
echo'<p>’ . get_post_meta($post->ID, ‘nameshow2′, true);'</p>’;
echo ‘<p>’ . $timeslots[$whichslot2] . ‘</p></div> - ‘;
echo $shortweek[$i];
echo ‘<div class=”not-on-air”>’;
echo'<p> </p>’;
echo ‘<p> </p></div>
$i = 0;
$week = array(“monday”, “tuesday”, “wednesday”, “thursday”, “friday”, “saturday”, “sunday”);
$shortweek = array(“mon”, “tues”, “wed”, “thurs”, “fri”, “sat”, “sun”);while ($i <=6) {
if (in_array($week[$i],$days2)) {
echo’‘;
}else { echo’
‘;
}
$i++;
}
echo ‘‘;
}
?>
</div><div class=”presenter-details”>
<?php
if (!empty($show_blurb)) {
echo ‘<div class=”about-show”><h4>ABOUT THEIR SHOW</h4><p>’ . $show_blurb . ‘</p></div>’;
}
if ($secondshow == ‘yes’) {
if (!empty($show_blurb2)) {
echo ‘<div class=”about-show”><h4>ABOUT THEIR SECOND SHOW</h4><p>’ . $show_blurb2 . ‘</p></div>’;
}
}
if (!empty($soundcloud)) {
echo ‘<div class=”souncloud-mixes”><h4>SOUNDCLOUD MIXES</h4>- ‘ . $soundcloud . ‘
</div>’;
}?>
</div>
<div class=”favourites”>
<?php
if (!empty($favourite_artist)) {
echo ‘<div class=”favourite-artist”><h4>MY FAVOURITE ARTIST</h4><div>’ . $favourite_artist . ‘</div></div>’;
}if (!empty($favourite_album )) {
echo ‘<div class=”favourite-album”><h4>MY FAVOURITE ALBUM</h4><div>’ . get_post_meta($post->ID, ‘fav_album_name’, true) . ‘<p>’ . $fav_album_artist . ‘</p></div>
</div>’;
}
?>
</div><div class=”artist-post”>
</div><!– end .artist-post –>
</div><!– end .atsng-col clearfix –></div><!– end #content –>
<?php get_footer(); ?>
<?php /*
function scrape_instagram($username, $slice = 9) {
if (false === ($instagram = get_transient(‘instagram-media-‘.sanitize_title_with_dashes($username)))) {
$remote = wp_remote_get(‘http://instagram.com/’.trim($username));
if (is_wp_error($remote))
return new WP_Error(‘site_down’, __(‘Unable to communicate with Instagram.’, $this->wpiwdomain));if ( 200 != wp_remote_retrieve_response_code( $remote ) )
return new WP_Error(‘invalid_response’, __(‘Instagram did not return a 200.’, $this->wpiwdomain));$shards = explode(‘window._sharedData = ‘, $remote[‘body’]);
$insta_json = explode(‘;</script>’, $shards[1]);
$insta_array = json_decode($insta_json[0], TRUE);if (!$insta_array)
return new WP_Error(‘bad_json’, __(‘Instagram has returned invalid data.’, $this->wpiwdomain));$images = $insta_array[‘entry_data’][‘UserProfile’][0][‘userMedia’];
$instagram = array();
foreach ($images as $image) {
if ($image[‘user’][‘username’] == $username) {
$image[‘link’] = preg_replace( “/^http:/i”, “”, $image[‘link’] );
$image[‘images’][‘thumbnail’] = preg_replace( “/^http:/i”, “”, $image[‘images’][‘thumbnail’] );
$image[‘images’][‘standard_resolution’] = preg_replace( “/^http:/i”, “”, $image[‘images’][‘standard_resolution’] );$instagram[] = array(
‘description’ => $image[‘caption’][‘text’],
‘link’ => $image[‘link’],
‘time’ => $image[‘created_time’],
‘comments’ => $image[‘comments’][‘count’],
‘likes’ => $image[‘likes’][‘count’],
‘thumbnail’ => $image[‘images’][‘thumbnail’],
‘large’ => $image[‘images’][‘standard_resolution’],
‘type’ => $image[‘type’]
);
}
}$instagram = base64_encode( serialize( $instagram ) );
set_transient(‘instagram-media-‘.sanitize_title_with_dashes($username), $instagram, apply_filters(‘null_instagram_cache_time’, HOUR_IN_SECONDS*2));
}$instagram = unserialize( base64_decode( $instagram ) );
return array_slice($instagram, 0, $slice);
}
*/
?>———————————————–
The cover[1] and cover[2] are the images supposed to pull in, but not sure if this is the problem?
Is there another way of inserting the images here instead of using cover[1] etc? You will see cover[0] is displaying the presenter image correctly.
<div class=”favourites”><?php
if (!empty($favourite_artist)) {
echo ‘<div class=”favourite-artist”><h4>MY FAVOURITE ARTIST</h4><div>’ . $favourite_artist . ‘</div></div>’;
}if (!empty($favourite_album )) {
echo ‘<div class=”favourite-album”><h4>MY FAVOURITE ALBUM</h4><div>’ . get_post_meta($post->ID, ‘fav_album_name’, true) . ‘<p>’ . $fav_album_artist . ‘</p></div>
</div>’;
}
?>
</div>Hope you can shed some light on this even if you can tell me it is not a Piklist issue! Any guidance will be appreciated at this time!
-
May 22, 2018 at 2:16 pm #9001
-
May 23, 2018 at 6:34 am #9004
jeanneParticipantHi!
This one:
piklist(‘field’, array(
‘type’ => ‘file’
,’field’ => ‘my_upload_field’
,’scope’ => ‘post_meta’
,’label’ => ‘Media Uploader’
,’options’ => array(
‘modal_title’ => __(‘Add File(s)’,’piklist’)
,’button’ => __(‘Add Images’,’piklist’)
)
));$image_id = get_post_thumbnail_id();
$cover = wp_get_attachment_image_src($image_id, ‘_thumbnail_id’);
$cover150 = str_replace(“.jpg”, “-150×150.jpg”, $cover[0]);$favourite_artist = get_post_meta($post->ID, ‘fav_artist_name’, true);
$favourite_album = get_post_meta($post->ID, ‘fav_album_name’, true);
$fav_album_artist = get_post_meta($post->ID, ‘fav_album_artist’, true);The images uploaded through this uploader does not show on the frontpage. The images appear to be pulled in as $cover[1] and $cover[2] :
if (!empty($favourite_artist)) {
echo ‘<div class=”favourite-artist”><h4>MY FAVOURITE ARTIST</h4><div>’ . $favourite_artist . ‘</div></div>’;
}if (!empty($favourite_album )) {
echo ‘<div class=”favourite-album”><h4>MY FAVOURITE ALBUM</h4><div>’ . get_post_meta($post->ID, ‘fav_album_name’, true) . ‘<p>’ . $fav_album_artist . ‘</p></div>
</div>’;
}Thanks for looking into this! Much appreciated!
-
-
AuthorPosts
- You must be logged in to reply to this topic.