Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter brickwicks

    (@brickwicks)

    Actually, no worries, have sorted it.

    Cheers,
    PB

    physalis

    (@physalis)

    Hey brickwicks,

    how did you sort it? There is no option like that…

    Cheers,
    physalis

    Do tell. It sucks when someone finds a solution and doesn’t share it!

    Hi Jmanko,

    since there was no update in this place, I went another way. But I think this might not be what you actually need.

    I wanted the content of a custom field from the current page/post to be displayed in the sidebar. I use Advanced Custom Fields to handle custom fields, and for this you can just use a shortcode like [acf field=”my_fieldname”] in a text widget, and it displays the content of it. Not sure if shortcodes in widget is enabled by default, this is a 3rd-party theme I use in that case.
    Since ACF supports full HTML content for their fields (even a WYSIWYG field), you can literally display anything with that in the sidebar. If you do not have that specific field on every page/post you can determine a) via ACF on what kind of content the field appears in the backend and b) use Widget Context for restricting visibility of the widget in the sidebar.

    Was this of any help or completely different from what you need?

    Cheers

    physalis

    Thanks for the update. No, I’m interested in the the Meta Key order field, which should order on the value of a custom field key, but it’s not.

    Thread Starter brickwicks

    (@brickwicks)

    Hi and first up, big apologies for not catching up with this. For all the help I’ve received through forums such as this, it’s pretty bad form not following up on a question.

    Having said that, I’m not sure this is what you’re after!

    Whilst for all I know there could be an easier way, I managed to get the custom fields data into the plugin by editing the plugin index.php (which I know leaves it open to destruction should their be an update…not ideal). It was my first time dealing with a custom post type I’d created. If I did it now I would save some bother by using a custom-post-type plugin as described above.

    Still, in index.php of the plugin I added a get_post_custom call and some extra args to the ‘while($lcptu->have_posts())’ etc line (around line 165?).

    while($lcptu->have_posts()) {
                        $lcptu->next_post();
                        $count++;
                        $id = $lcptu->post->ID;
      				$custom = get_post_custom($id);
    					$title = $custom["Product_title"][0];
    					$sets = $custom["Product_sets"][0];
    					$status = $custom["Product_status"][0];
    					$price = $custom["Product_price"][0];
    					$shipping = $custom["Product_shipping"][0];
    					$var1 = $custom["Product_var1"][0];
    					?>
                        <li class="post-<?php echo $id; ?> <?php echo ($count%2)?'odd':'even'; ?>">
                            <h4 class="tm_lcptu_post_title"><?php echo '<a href="'.get_permalink($id).'" class="tm_lcptu_post_title_link">'.get_the_title($id).'</a>'; ?></h4>
    
                            <?php
                            if($instance['show_thumbnails'] && $instance['show_thumbnails'] == 'yes'){
                                if(has_post_thumbnail($id)) {
                                    echo '<a class="tm_lcptu_post_thumbnail" href="'.get_permalink($id).'">';
                                    if($instance['thumbnail_format']) {
                                        if($instance['thumbnail_format'] != '0')
                                            $image = wp_get_attachment_image_src(get_post_thumbnail_id($id), $instance['thumbnail_format']);
                                        elseif($instance['thumbnail_width'] > 0 && $instance['thumbnail_height'] > 0)
                                            $image = wp_get_attachment_image_src(get_post_thumbnail_id($id), array($instance['thumbnail_width'], $instance['thumbnail_height']));
                                        else
                                            $image = wp_get_attachment_image_src(get_post_thumbnail_id($id));
                                        if($instance['thumbnail_width'] > 0)
                                            $image[1] = $instance['thumbnail_width'];
                                        if($instance['thumbnail_height'] > 0)
                                            $image[2] = $instance['thumbnail_height'];
                                        echo '<img class="pb_border" src="'.$image[0].'" alt="'.$lcptu->post->post_title.'" width="'.$image[1].'" height="'.$image[2].'" />';
                                    }
                                    echo '</a></br>
                                    <p class="pb_sideprice">£'.$price.'</p>
                      <p>';
                      		if ($status=='In Stock'){
                      		echo print_wp_cart_button_for_product(''.$title.'',$price,$shipping,$var1); }
                      		elseif ($status=="Out of Stock"){
                      		echo '<strong>Sorry - Out of stock at present</strong>'; }
                      		else {
                      		echo ''; }
                      		echo'</p>';

    Does that help?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Custom Fields’ is closed to new replies.