Struggling to do CustomPress single.php code

Hi

I tried following the instructions and could not get the page for single.php to produce the page automatically. I did the 777 stuff and even changed back to the default theme. In the end I created the file called single-member.php but I am struggling to edit it to produce the desired results.

I have 2 taxonomies - 'associate' and 'accredited' and 2 custom fields 'first name' and 'surname' just while experimenting. If I knew exactly where to put the code for taxonomies and custom fields I could probably get there.
<?php echo get_the_term_list( $post->ID, 'associate', 'Before: ', ', ', 'After' ); ?>
<?php echo get_the_term_list( $post->ID, 'accredited', 'Before: ', ', ', 'After' ); ?>

and

<?php echo get_post_meta( $post->ID, '_ct_text_4e27389994b6b', true ); ?>
<?php echo get_post_meta( $post->ID, '_ct_text_4e27776d41d28', true ); ?>

<?php
/**
* The Template for displaying all single member posts.
*
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/

get_header(); ?>

<div id="container">
<div id="content" role="main">

<?php
/* Run the loop to output the post.
* If you want to overload this in a child theme then include a file
* called loop-single.php and that will be used instead.
*/
get_template_part( 'loop', 'single' );
?>

</div><!-- #content -->
</div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

  • Philip John
    • DEV MAN’s Apprentice

    Hiya,

    I'm going to ask the developer about that - we did have an issue but I'm sure it was resolved a while ago. Can you tell me what version of the plugin and WordPress you have installed please?

    As for custom fields, you can place them anywhere inside your theme's loop. I see you're using Twenty Ten. Therefore, you'll want to create a child theme into which you need to copy loop.php.

    You can then paste the embed code for your custom fields into your new copy of loop.php to display them on your site.

    Cheers,
    Phil

  • Lugh
    • Flash Drive

    Thanks Phil for getting back to me.

    I was using thesis but decided to crack this in wordpress default theme and then progress to the other theme if possible. May not be.

    I have only downloaded it in the last 2 days using the big button provided and I am on 1.1.3 version of the plugin.

    I was following the instructions to the letter and hence created the single-member.php but could not see a connection between the code given in the instructions and the code copied from single.php.

    I am happy to work out the child theme stuff and is it just custom fields I put in there or taxonomies too?

    Regards

    Lugh

    P.S. I was on wp 3.1 and have upgraded to 3.2.1 and thought I would have another go but ended up with server error.

  • Lugh
    • Flash Drive

    Hi Phil

    I've since set up a new sub directory and made sure that wp was the 3.2.1. On changing the permission to 777 for the theme I again got the server error on clicking the button in custom press settings. Changedit back to 755 and all is well with it but no single[post type].php file.

    I will print off the child theme stuff and work through that.

    Regards

    Lugh

  • Lugh
    • Flash Drive

    Hi Phil,

    Followed the instructions for the child theme and created that successfully. In the loop file I found code that matched that in the instructions. I put the embed code in the appropriate places.

    I set the permission for the child theme to 777 and although it does not create the single [post type].php it does not cause a server error which is a relief. However, all I get on the post url is whatever I write on the post title and not the information from the custom fields.

    Regards

    Lugh

  • Philip John
    • DEV MAN’s Apprentice

    Hiya Lugh,

    Okay good that you've gotten that far. Your custom posts won't contain your custom fields by default, you will need to add them in.

    Go to Custom Press > Content Types > Custom Fields.

    When you hover over each custom field an "Embed Code" link will appear. Click that and copy the code.

    Paste that code into your new loop.php where you want the custom field value to appear.

    Cheers,
    Phil

  • Lugh
    • Flash Drive

    Hi Phil

    In the loop file I found code that matched that in the instructions. I put the embed code in the appropriate places.

    I have copied it already into the loop and the 2 custom fields appear at the bottom of the post. Where they are not appearing is when I click 'view post' there is no sign of those fields there. All I see is whatever I put in the post title.

    I set the permission for the child theme to 777 and although it does not create the single [post type].php it does not cause a server error which is a relief. However, all I get on the post url is whatever I write on the post title and not the information from the custom fields.

    I think that part of the plugin is not working properly or the instructions are wrong. .

    Regards

    Lugh

  • ehegwer
    • New Recruit

    I'm having an issue with this, too.
    WP 3.2.1
    BP 1.2.9
    CP 1.1.3

    I've got the custom Fields checkbox enabled,

    Here''s my error on my custom single-vendor.php page
    Warning: Invalid argument supplied for foreach() in site/wp-content/plugins/buddypress/bp-themes/bp-default/single-vendor.php

    and here's the code copied from the plugin box

    <?php if ( get_post_meta(
    $post->ID, '_ct_selectbox_4e29789c40e39', true ) ) { foreach (
    get_post_meta( $post->ID, '_ct_selectbox_4e29789c40e39', true ) as
    $value ) { echo $value . ', '; }} ?><br/>
  • Lugh
    • Flash Drive

    Have got through some of the problems but advised by S H Mohanjith to ask here for help with the final piece that I need. I cannot get the contents of the custom posts to appear on the url page. Got the boxes and all of that. Is it possible to have the code for the single-[custom post].php? I can only see tiny bits of it in the instructions which I've printed out.

  • Mason
    • DEV MAN’s Sidekick

    Hiya Lugh,

    I took a look at the code and it all looks correct. Do you have that file saved as single-CustomPostType.php?

    Also, you're saying that the elements like "Membership" are displaying, but the actual custom content is not? Is that correct?

    Finally, gotta link?

    Thanks!

  • Lugh
    • Flash Drive

    Hi

    Yes it is saved as single [name].php?

    Yes the those bits are displaying OK. With the taxonomy for 'town' it is retaining the information and putting the words 'before and after' around it which is easily stopped and I also need to add code so the text appears line by line.

    With the custom posts it is not retaining the information for Degree and Diplomas after I press the update button so I don't think my code is right. It retains the Membership with one option highlighted. I've tried to work it out from the notes given with installation but not succeeded whereas the code around taxonomy was legible.

    I've put a link in the last line of the paste that you already have the link for.

    Regards

    Lugh

  • Mason
    • DEV MAN’s Sidekick

    Hiya Lugh,

    Ok, I think I see the problem. The embed codes provided by CustomPress have to be placed inside the loop to work correctly.

    TwentyTen does an unusual thing in that it actually puts the loop inside it's own file. This means we have an additional step to getting things working than normal.

    You'll need to copy the loop-single.php file and name it something else like loop-CPT.php. From here you can place all your above embed codes. My suggestion would be to start at line 36 of your new file, but you can play around with it once you have the information showing up.

    Now, go back to your single-CPT.php and delete it. Make a new copy of single.php and rename it to single-CPT.php. Inside the new file we only need to change one word. On line 20 replace the word single with whatever you're using for CPT.

    Save all your files and refresh the page on your site.

    Let us know if that does the trick. Like I said, normally you'd not have to do this additional step, but because of the way twentyten is written, this is necessary.

    Thanks!

  • Lugh
    • Flash Drive

    Hi Mason

    I had left it aside while I worked with Supporter. I have followed the instructions but I am getting nothing at all apart from the Post title coming up on the url.

    I am not fixated on using this theme. Is it possible to recommend a theme from WPMU that would work with CustomPress? I have uploaded edu clean and WPMU Triden 2.1.5 themes but using them did not seem too straight forward either.

    Regards

    Lugh

    P.S There is one in your showcase called Agnes Inversiones. Is it possible to know what theme they used?

  • Lugh
    • Flash Drive

    Hi I had a look at the source code on the Agnes Inv .using Firefox and it appears to be there own theme. I stayed on live support for the last few hours but got no acknowledgement of my presence.

    Also wondering if you could have a quick look at this: http://pastebin.com/
    This workaround failed so I uploaded the edu clean theme and I'm not sure if I am putting the custom fields code in the right place. Well nothing is happening so I expect I have not got it right. I've put a note before the 2 lines of code that should appear on the url but don't.

  • Philip John
    • DEV MAN’s Apprentice

    Hiya,

    Sorry for the delay here - Mason is caught up dealing with something urgent elsewhere.

    Can we go back to the TwentyTen theme as I think it would be best to sort that out for the sake of understanding how it works.

    Can you tell me exactly what files you have added and their contents please?

    Thanks,
    Phil

  • Lugh
    • Flash Drive

    Hi Phil

    I will do but I'm sure you can appreciate I want a solution and the developer must have had a particular theme in mind where it actually worked. I've been in a meeting all day and so another day lost as I could not respond till now. I started this query last Thursday.The supporter theme that I have an outstanding query on also leaves me stuck.

    Regards

    Lugh

  • Mason
    • DEV MAN’s Sidekick

    Hiya Lugh,

    Apologies for the delay here. The theme being used in the showcase entry you mentioned is a custom one designed for that site.

    As to ones that I'd recommend for easy of use, even the new twentyeleven theme included with WordPress would be easier/more logical than the twentyten theme.

    Ones from here that I'd recommend would be the new Simple Market theme (very light-weight theme) or our WPMU Dixi and Nelo themes.

    Those are the easiest ones to sorta wrap your head around the theme structure (in my opinion).

    Here's a really great in-depth article on custom post types. It may help explain how custom post types are created, used, and implemented into a theme:
    http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress

    Let us know how it goes for ya.

    Thanks!

  • Lugh
    • Flash Drive

    Hi Phil and Mason

    I am delighted to report success.

    I started from scratch with a new single sub-domain and the Single Market theme which by the way is a beautiful theme. I did not bother with multisite which may disappoint you but I'm over the moon with this.

    Many thanks,

    Lugh

    P.S. Is anyone writing a plugin for searching the custompress information.? You probably don't want to tell me if they are. :wink:

  • Mason
    • DEV MAN’s Sidekick

    Hiya Lugh,

    Congrats! And big thanks to Phil for stepping in here as well.

    P.S. Is anyone writing a plugin for searching the custompress information.? You probably don't want to tell me if they are. :wink:

    Did you set the Query var to true? You set this value when creating the post type in CustomPress. This will allow the new post to be included by any WordPress search on your site.

    If you want to search and pull results from a specific post type you'd do something like this in your theme's function file:

    function filter_search($query) {
        if ($query->is_search) {
    	$query->set('post_type', 'CPT');
        };
        return $query;
    };
    add_filter('pre_get_posts', 'filter_search');
  • Lugh
    • Flash Drive

    I gave up the struggle and I'm paying someone else to sort it out without the plugin. I ran out of time.

    However, I discovered a few avenues that somebody else might like to explore.
    One is Gravity Forms plus http://www.seodenver.com/gravity-forms-addons/ and an explanation of shortcode from http://www.seodenver.com/gravity-forms-shortcode/

    The other possibility is a plugin called Relevanssi http://www.relevanssi.com/buy-premium/ and this article at http://wp-evangelist.com/2011/02/extending-wp-search/

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.