WordPress.org

Ready to get started?Download WordPress

Forums

Custom Content Type Manager
Add Custom Content Posts/Items to a Page (13 posts)

  1. J
    Member
    Posted 2 years ago #

    Hi,

    First let me say this this plugin is amazing!

    Ok so what i'm trying to do is have the items or posts created in one of the new custom content type that I've created show up in a specific page but in the look i've set up for it in its single-{name}.php page.

    I've seen reply for this when people want it these to be listed on the home page or index page but I want to do it in another page.

    So to be more specific, I've created the single-team_members.php and styled it to display the posts the way I want. now I want them to to show up on my "Our Team" page. i've created a unique page template for that page.

    I've tried two things.

    1. I've used this plugin: http://wordpress.org/extend/plugins/sf-pages-for-custom-posts/ and it works in allowing me to display these custom posts on that page but it gives me only several options of page types to choose from and my single-team_members.php is not one of them and I can't figure out how to add it.

    2. I have tried to take the code from my single-team_members.php file and add it to my custom page template for Our Team page but it messes up the page as it doesn't know to find the correct post types.

    is there a way to just call out single-team_members.php from within my custom page template? just sort like get_sidebar or get_footer ?
    what other solution might I have for this?

    option number one above was the closest as the plugin just easily took care of displaying the custom post types in the chosen page, but just not in the right style, maybe someone can think of a way to tinker with that? (this seems to be something that several people have asked about)

    any suggestion would help.

    Thanks in advance,
    J

    http://wordpress.org/extend/plugins/custom-content-type-manager/

  2. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks for the note -- sorry I didn't see this post until now. I would do this:

    Set up a dedicated page (not a post) that has the styling you want (because only WordPress pages can have their own dedicated templates). Then on that page, you can put a call to SummarizePosts and GetPostsQuery (part of the CCTM package, but you can see examples here: http://code.google.com/p/wordpress-summarize-posts/wiki/Examples_get_posts), and you can loop over the search results there. You can also use the Summarize Posts widget (http://code.google.com/p/wordpress-custom-content-type-manager/wiki/Widget) to accomplish this same loop affect.

    Re the single pages... WP is unfortunately not very flexible here... the way it handles URLs is extremely confined and not easily customizable. So just use the single-{post-type}.php theme file to style these. That's WP's way of doing this. Trying to move that styling and logic stuff to a page is like petting a cat backwards ==> sparks, mad kitty. It's hard for WP to do stuff like that, and I'm not sure what benefit you'd get from it. WordPress is a can of worms when you start customizing off the narrow accepted path, so it's probably much less of a headache to just use the dedicated single-....php theme file and be done with it.

  3. J
    Member
    Posted 2 years ago #

    Thanks for the reply,

    I think I have explained part of it in a way that is confusing. Let me try to clarify and perhaps you can tell if I'm going about this the wrong way.

    I am trying to use this plugin to do something that no other plugin allows to do as far as I can tell. I am trying to create Tabs/Modules in the admin area that will allow the site's owner to enter content based on specific predefined fields which will in turn populate different sections of the site per a specific design.
    For example, a page for Team Members, a page for Featured Businesses etc'

    So i want the Team Members page to display a list of all the Custom Posts of Team Members and the Featured Business page to display all Custom Posts of Featured Business, and when one of them is click it will go to that page/post displaying the full details of that post. (and I have several more of those modules)

    Short of writing a custom plugin for each of these, this is the fastest and easiest way I found to do it, which is why I thought this plugin is brilliant, but perhaps I'm using it for something it wasn't intended for.

    Now if I understand correctly, I can use the summarize-posts to display the list of custom posts in a styled way and use the single-{} php to display the individual post, right?
    But what you are saying is that I can't really display the individual custom posts under the specific page the summary was on?

    Is there a different/better way to do what I am trying to do? or does that require a custom plugin? All I am trying to do is allow the owner to not have to worry about styling and html and be able to add more of the same type of content (like team members) by just adding their name, image, title, company, etc' in the correct fileds and hit publish and it will all show up correctly in the right way and on the right place on the site.

    thoughts?

  4. J
    Member
    Posted 2 years ago #

    Update:

    I have managed to create page template that displays the custom individual post perfectly in the right way. However I have tried to use the summarize-posts to display the list of custom posts but I can't seem to figure out how to customize the look of that.

    It seems the php part is beyond me, and the shortcode customization is just not working. I have followed examples such as this but it is not displaying anything except the code itself.

    I am trying to display the image, title and an excerpt

  5. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    I'm not sure I follow you exactly, but maybe you're approaching this in an overly complicated way. The relation fields can be defined to list very specific criteria, e.g. to link to one or many related posts (e.g. allowing you select a related team-member post when creating a business post). I'm guessing that's what you've done to interlink your content types, yes?

    You absolutely can display the info of a related post on another post on the front-end: that's EXACTLY what the Summarize Posts and its classes do: it gives you a sensible and thorough API into the WP database (instead of the half-assed and caveat-prone wonkiness of WP_Query, get_posts() etc).

    You'll have to paste your code in the pastebin where I can see it: I can't debug code I can't see. Don't paste it in here if it's long, otherwise your post will get moderated.

  6. J
    Member
    Posted 2 years ago #

    I'm not sure what you mean. I am not trying to connect different custom post types with one another (I was just giving two examples).

    I am trying to list my custom posts.
    If I paste the following code on the My Team page:

    [summarize-posts post_type="team_members" limit="10"]

    I get a list of just the post names.

    I am trying to post the member name, their title, their image and and excerpt of their description, all content entered with the custom fields created with this plugin for this specific post type.

    I have tried using this:
    [summarize_posts post_type="team_members"] [+post_title+] [/summarize_posts]

    All this does is display the list as before (just titles) and under the list it displays "[+post_title+]" (these exact characters, this is not a place holder) as a hyperlink.

  7. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Ok, if you're using the shortcode, then you just need to use the available placeholders, e.g.

    [summarize-posts post_type="team_members"]
    [+post_title+]<br/>
    Member Name: [+member_name+]<br/>
    Member title: [+member_title+]<br/>
    [/summarize-posts]

    The exact placeholders correspond to whatever custom fields you've defined for that post-type. Everything between the summarize-posts tags is treated as a formatting string.

    If you add "help=1" to your shortcode, e.g.

    [summarize-posts post_type="team_members" help=1]

    You'll get a lot of debugging information, and importantly, you'll be able to see what attributes are available in your result set, e.g.

    Array
    (
        [0] => Array
            (
                [ID] => 1774
                [post_author] => 1
                [post_date] => 2012-05-01 23:23:37
           // ....
                [team_member] => Bob Smith
          //....etc...

    So that would tell you that [+post_date+] would print out "2012-05-01 23:23:37" and that [+team_member+] would print out "Bob Smith".

    The shortcodes are useful in a pinch, but the PHP variation of these in your theme files have a lot more flexibility.

  8. J
    Member
    Posted 2 years ago #

    Perfect, this is what I was looking for.

    but the member_image returns a number (210) both in the result page and the debug instead of a url:

    [member_image] => 210
      [member_name] => John Smith
      [member_title] => CEO

    I'm guessing this is an image or attachment id.

    Is there a way to get the url? or alternatively a way to display an image by an id?

    Thank you for taking the time to dig into this with me.

  9. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Yes, the number is a foreign key, and if I had a nickel...

    This is why you need to use the PHP: you can convert the integer to the link or to whatever you need.

  10. J
    Member
    Posted 2 years ago #

    I have searched the wiki and have not found an example or instructions on how to do that.

  11. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    It's just WP 101 at that point: you get a number representing a post or an image. You convert it to what you need using any number of available WP functions, e.g. get_permalink() or get_post() etc.

    You can use the CCTM's get_post Output Filter to help here -- it'll take a post ID and get all available attributes:

    http://code.google.com/p/wordpress-custom-content-type-manager/wiki/get_post_OutputFilter

  12. J
    Member
    Posted 1 year ago #

    Hi,

    So i decided to come back here and write how I solved this issue in my case, so this thread doesn't remain unsolved and especially if anyone else ends up here and has the same issue. (and maybe as a suggestion to you fireproofsocks, as an idea to implement in the future).

    I have found a plugin called LoopBuddy which seems to work flawlessly with CCTM.

    It allows you to create a query for a specific custom post type and then create a layout of how the loop for that post type will be displayed.

    Then all you have to do is pasted the shortcode for that loop in the page you want and viola!

    but in searching for this solution i realized that a LOT of people are searching for it as well so I think the plugin still falls short of what it could be I still think your plugin is amazing, fireproof.

  13. fireproofsocks
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for the feedback -- please post feature requests in the issue tracker.

    I think with some more documentation, the common task of iterating over loops and formatting results will be clearer for everyone. There are some issues in the issue tracker related specifically to documentation. For me, it's just a matter of finding/making the time to do it.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic