WordPress.org

Ready to get started?Download WordPress

Forums

Custom Content Type Manager
[resolved] Listing Format With Specific Custom Fields of a Specific Custo (58 posts)

  1. WebmistressM
    Member
    Posted 2 years ago #

    Im curious to know if anyone has used CCTM to create a listing of information based on a content type created with CCTM. Basically like a foreach statement that lists each item in that content type, field by field.

    Anyone know how this might be done

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

  2. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Sure, check out WP's get_posts() function or try my other plugin: Summarize Posts. There are lots of examples on its Wiki: http://code.google.com/p/wordpress-summarize-posts/wiki/Examples_get_posts

    The simplest might just be a shortcode in your post:

    [summarize-posts post_type="your_post_type"]

  3. WebmistressM
    Member
    Posted 2 years ago #

    I think [summarize-posts post_type="your_post_type"] might be too generic/non-specific but I see. I did download the Summarize Posts plugin but I just wasnt sure if I should make a template file or if there is a shortcode button on a page's body/description to add things in.

    My content type has over 8 fields but I want to hide (i.e. not show) about 60% of them on this static wordpress page

  4. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    The Summarize Posts has a LOT of options, so you can really fine-tune it to return EXACTLY the options you want. As far as which fields you want to show, that's all a matter of how you format your results. The simple way to specify the format of each result is by using the full version of the tag:

    [summarize_posts]<li>[+post_title+]</li>[/summarize_posts]

    Where the wrapped text is used as a formatting string:
    <li>[+post_title+]</li>

    You can use a lot of different placeholders in there: basically any column from wp_posts and any custom field name can be used, e.g.
    <li>[+post_excerpt+] [+post_date+] <br/>[+my_custom_field+]</li>

    No button for the shortcode yet... but that's coming.

  5. WebmistressM
    Member
    Posted 2 years ago #

    It baffles me that I cannot get shortcodes to parse in a post or a page. I tried typing it in using the wysiwyg editor as well as the HTML editor. Ill have to look into this and find out which plugin is farking it up.

  6. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Shortcodes parse ONLY in WordPress' built-in "content" area. They will not parse in a WYSIWYG custom field. Are you putting them in a custom field perchance?

  7. WebmistressM
    Member
    Posted 2 years ago #

    I am actually not putting shortcodes in a custom field. Im puttign it in the main body of the post or page. I also have NextGEN gallery in this same install so I know shortcodes work.

  8. WebmistressM
    Member
    Posted 2 years ago #

    http://imagebin.org/180101

    This is where im entering it

  9. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Ok, it threw me for a long time that shortcodes only parsed in the content area, that's why I mention it.

    Do those tags interfere with the shortcode? Try adding "help=1" to your summarize_posts code and you'll get debugging info.

  10. WebmistressM
    Member
    Posted 2 years ago #

    `Arguments

    For more information on how to use this function, see the documentation for the GetPostsQuery::get_posts() function.

    limit: --
    offset: --
    orderby: ID
    order: DESC
    include: --
    exclude: --
    append: --
    meta_key: --
    meta_value: --
    post_type: Array (order_queue)
    omit_post_type: Array (revision)
    post_mime_type: --
    post_parent: --
    post_status: Array (publish)
    post_title: --
    author: --
    post_date: --
    yearmonth: --
    date_min: --
    date_max: --
    date_format: --
    taxonomy: --
    taxonomy_term: --
    taxonomy_slug: --
    taxonomy_depth: 1
    search_term: --
    search_columns: Array (post_title, post_content)
    join_rule: AND
    match_rule: contains
    date_column: post_modified
    paginate: false

    Raw Database Query:
    SELECT wgm_posts.* , parent.ID as 'parent_ID' , parent.post_title as 'parent_title' , parent.post_excerpt as 'parent_excerpt' , author.display_name as 'author' , thumbnail.ID as 'thumbnail_id' , thumbnail.guid as 'thumbnail_src' , metatable.metadata FROM wgm_posts LEFT JOIN wgm_posts parent ON wgm_posts.post_parent=parent.ID LEFT JOIN wgm_users author ON wgm_posts.post_author=author.ID LEFT JOIN wgm_term_relationships ON wgm_posts.ID=wgm_term_relationships.object_id LEFT JOIN wgm_term_taxonomy ON wgm_term_taxonomy.term_taxonomy_id=wgm_term_relationships.term_taxonomy_id LEFT JOIN wgm_terms ON wgm_terms.term_id=wgm_term_taxonomy.term_id LEFT JOIN wgm_postmeta thumb_join ON wgm_posts.ID=thumb_join.post_id AND thumb_join.meta_key='_thumbnail_id' LEFT JOIN wgm_posts thumbnail ON thumbnail.ID=thumb_join.meta_value LEFT JOIN wgm_postmeta ON wp_posts.ID=wgm_postmeta.post_id LEFT JOIN ( SELECT wgm_postmeta.post_id, CONCAT( GROUP_CONCAT( CONCAT(wgm_postmeta.meta_key,'::::', wgm_postmeta.meta_value) SEPARATOR ',,,,'), '$$$$') as metadata FROM wgm_postmeta WHERE wgm_postmeta.meta_key NOT LIKE '\_%' GROUP BY wgm_postmeta.post_id ) metatable ON wgm_posts.ID=metatable.post_id WHERE ( 1 AND wgm_posts.post_type NOT IN ('revision') AND wgm_posts.post_type IN ('order_queue') AND wgm_posts.post_status IN ('publish') ) GROUP BY wgm_posts.ID ORDER BY wgm_posts.ID DESC

    [summarize-posts orderby="ID" order="DESC" post_type="order_queue" omit_post_type="revision" post_status="publish" taxonomy_depth="1" search_columns="post_title,post_content" join_rule="AND" match_rule="contains" date_column="post_modified"]
    Comparable Shortcode:

    [summarize-posts orderby="ID" order="DESC" post_type="order_queue" omit_post_type="revision" post_status="publish" taxonomy_depth="1" search_columns="post_title,post_content" join_rule="AND" match_rule="contains" date_column="post_modified"]

  11. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    That proves that the shortcode is parsing, so that's something to celebrate.

    Try grabbing the dev version -- I think I borked a bug with the "search_columns" parameter in that...

    From the download page: http://wordpress.org/extend/plugins/summarize-posts/download/

    You should be able to download the dev version:
    http://downloads.wordpress.org/plugin/summarize-posts.zip

  12. WebmistressM
    Member
    Posted 2 years ago #

    I did try and get the dev version. Problem still exists. Other plugins installed (which could conflict)

    JJ NextGen JQuery Slider, NextGEN Gallery, WP-Mail-SMTP, jQuery Colorbox

  13. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    I don't think it's a conflict... I would back off on the parameters until you get results. Like if you know you have posts on your site, then try searching for them:

    [summarize_posts post_type="post"]

    Then try listing your custom post types:

    [summarize_posts post_type="order_queue"]

  14. WebmistressM
    Member
    Posted 2 years ago #

    <code>[summarize_posts post_type="post"]</code>

    is what I put in a page post

  15. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Why do you put the code tags there?

  16. WebmistressM
    Member
    Posted 2 years ago #

    I have tried just [summarize_posts post_type="post"] without code tags and the same result happens`

    Summarize Posts
    Errors
    There were no errors.
    Arguments

    For more information on how to use this function, see the documentation for the GetPostsQuery::get_posts() function.

    limit: --
    offset: --
    orderby: ID
    order: DESC
    include: --
    exclude: --
    append: --
    meta_key: --
    meta_value: --
    post_type: Array (post)
    omit_post_type: Array (revision)
    post_mime_type: --
    post_parent: --
    post_status: Array (publish)
    post_title: --
    author: --
    post_date: --
    yearmonth: --
    date_min: --
    date_max: --
    date_format: --
    taxonomy: --
    taxonomy_term: --
    taxonomy_slug: --
    taxonomy_depth: 1
    search_term: --
    search_columns: Array (post_title, post_content)
    join_rule: AND
    match_rule: contains
    date_column: post_modified
    paginate: false

    Output Type
    ARRAY_A

  17. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    [summarize_posts post_type="post"]

    That shouldn't print out debugging info. The above debugging info should only appear if you set the help=1 parameter. Did you set something there and not paste it? Or is there caching somewhere that you need to clear?

    I found a bug with the dev version of Summarize Posts -- inside of includes/GetPostsQuery.php around line 1520:

    // $r->the_content = apply_filters('the_content', $r->post_content);

    Comment that line out.

    This is really impossible to troubleshoot without access to your site: without seeing your database, I can't tell you what the query there should return. There is a bug tracker if this is a bug: http://code.google.com/p/wordpress-summarize-posts/issues/list

  18. WebmistressM
    Member
    Posted 2 years ago #

    Hmm...seems like communication is not breaking down. Yes, I got the error output from adding help=1. The result I get is still that there are no errors (as I copy/pasted just before that).

    I idd check out summarize-posts/includes/GetPostsQuery.php and 1520 is already commented out.

  19. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Ok, good. The next thing I would check is to copy the SQL query and paste it into phpMyAdmin (or equivalent SQL client) and see if the query returns any errors. It could just be that there are no rows meeting your criteria.

  20. WebmistressM
    Member
    Posted 2 years ago #

    The following sql query:

    SELECT wgm_posts.* , parent.ID as 'parent_ID' , parent.post_title as 'parent_title' , parent.post_excerpt as 'parent_excerpt' , author.display_name as 'author' , thumbnail.ID as 'thumbnail_id' , thumbnail.guid as 'thumbnail_src' , metatable.metadata FROM wgm_posts LEFT JOIN wgm_posts parent ON wgm_posts.post_parent=parent.ID LEFT JOIN wgm_users author ON wgm_posts.post_author=author.ID LEFT JOIN wgm_term_relationships ON wgm_posts.ID=wgm_term_relationships.object_id LEFT JOIN wgm_term_taxonomy ON wgm_term_taxonomy.term_taxonomy_id=wgm_term_relationships.term_taxonomy_id LEFT JOIN wgm_terms ON wgm_terms.term_id=wgm_term_taxonomy.term_id LEFT JOIN wgm_postmeta thumb_join ON wgm_posts.ID=thumb_join.post_id AND thumb_join.meta_key='_thumbnail_id' LEFT JOIN wgm_posts thumbnail ON thumbnail.ID=thumb_join.meta_value LEFT JOIN wgm_postmeta ON wp_posts.ID=wgm_postmeta.post_id LEFT JOIN ( SELECT wgm_postmeta.post_id, CONCAT( GROUP_CONCAT( CONCAT(wgm_postmeta.meta_key,'::::', wgm_postmeta.meta_value) SEPARATOR ',,,,'), '$$$$') as metadata FROM wgm_postmeta WHERE wgm_postmeta.meta_key NOT LIKE '\_%' GROUP BY wgm_postmeta.post_id ) metatable ON wgm_posts.ID=metatable.post_id WHERE ( 1 AND wgm_posts.post_type NOT IN ('revision') AND wgm_posts.post_type IN ('post') AND wgm_posts.post_status IN ('publish') ) GROUP BY wgm_posts.ID ORDER BY wgm_posts.ID DESC

    returned this in PHPMYAdmin:

    #1054 - Unknown column 'wp_posts.ID' in 'on clause'

  21. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Aha. You have discovered a bug :) Thanks for following up on this with me!

    I just committed the fix in SVN, so that dev version link should be updated in a few... but if you want to fix it, go into includes/GetPostsQuery.php around line 822:

    LEFT JOIN {$wpdb->postmeta} ON wp_posts.ID={$wpdb->postmeta}.post_id

    Should be changed to
    LEFT JOIN {$wpdb->postmeta} ON {$wpdb->posts}.ID={$wpdb->postmeta}.post_id

    I accidentally hardcoded the database table name prefix -- your install uses "wgm_" instead of the default "wp_", so the join failed.

  22. WebmistressM
    Member
    Posted 2 years ago #

    Yipe. That gave me one hell of an error:

    Fatal error: Allowed memory size of 152043520 bytes exhausted (tried to allocate 20 bytes) in /var/www/wildgasmasks3/wp-includes/wp-db.php on line 887

    Took a long time to pull up the page with this.

    So I tried putting in the content type order_queue,
    [summarize_posts post_type="order_queue" help="1"]

    Gave me no errors but I tried the following query in phpadamin.

    SELECT wgm_posts.* , parent.ID as 'parent_ID' , parent.post_title as 'parent_title' , parent.post_excerpt as 'parent_excerpt' , author.display_name as 'author' , thumbnail.ID as 'thumbnail_id' , thumbnail.guid as 'thumbnail_src' , metatable.metadata FROM wgm_posts LEFT JOIN wgm_posts parent ON wgm_posts.post_parent=parent.ID LEFT JOIN wgm_users author ON wgm_posts.post_author=author.ID LEFT JOIN wgm_term_relationships ON wgm_posts.ID=wgm_term_relationships.object_id LEFT JOIN wgm_term_taxonomy ON wgm_term_taxonomy.term_taxonomy_id=wgm_term_relationships.term_taxonomy_id LEFT JOIN wgm_terms ON wgm_terms.term_id=wgm_term_taxonomy.term_id LEFT JOIN wgm_postmeta thumb_join ON wgm_posts.ID=thumb_join.post_id AND thumb_join.meta_key='_thumbnail_id' LEFT JOIN wgm_posts thumbnail ON thumbnail.ID=thumb_join.meta_value LEFT JOIN wgm_postmeta ON wgm_posts.ID=wgm_postmeta.post_id LEFT JOIN ( SELECT wgm_postmeta.post_id, CONCAT( GROUP_CONCAT( CONCAT(wgm_postmeta.meta_key,'::::', wgm_postmeta.meta_value) SEPARATOR ',,,,'), '$$$$') as metadata FROM wgm_postmeta WHERE wgm_postmeta.meta_key NOT LIKE '\_%' GROUP BY wgm_postmeta.post_id ) metatable ON wgm_posts.ID=metatable.post_id WHERE ( 1 AND wgm_posts.post_type NOT IN ('revision') AND wgm_posts.post_type IN ('order_queue') AND wgm_posts.post_status IN ('publish') ) GROUP BY wgm_posts.ID ORDER BY wgm_posts.ID DESC

    Now, the current error on the phpmyadmin level is:
    MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0036 sec )

    I guess now that it is working, I just need to feed it thee info so it knows what custom fields within order_queue to pull up and what markup it is to be surrounded by..

  23. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Well, we have moved out of errors with the code, and hit smack into memory limits on your server (out of the frying pan and into the fire haha).

    So that beastly query of mine was geared to do one thing: retrieve a post in its entirety, with its custom fields, taxonomies, and all related fields, all tweakable by the query object. That makes the queries faster and the application leaner, but as you have noticed, it requires more resources.

    There is a setting for the Summarize Posts plugin relating to the mysql max len, but you should get an error if that issue is popping up.... you can try upping that number to see if that helps anything.

    Try this -- edit the includes/SummarizePosts.php file around line 39, and update this setting:
    public static $manually_select_postmeta = true;

    That will force a more simplistic database query -- it's slower, but it's not as resource intensive.

    See if that works any better. The raw MySQL query is useful as a reality check to see if you actually have any rows in the database meeting those criteria (and as way for me to troubleshoot the generation of that query).

  24. WebmistressM
    Member
    Posted 2 years ago #

    Yeah. I have pretty good memory on my server so I was shocked that there was a problem. Than again, the original query was

    [summarize_posts post_type="post" help="1"]

    With [summarize_posts post_type="order_queue" help="1"] and editing that line in /includes/SummarizePosts.php, it now is speedy again.

    In phpMyAdmin, I ran the query and got: MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0035 sec ) again

  25. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    to clarify: editing this made it speedy?

    public static $manually_select_postmeta = true;

  26. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    And while I'm thinking about it, do you think you could share with me a copy of your MySQL configuration file? It's named my.cnf, and it's usually located inside /etc/ on linux servers. Even though your server may have a lot of memory, there are probably constraints on how much gets allocated to MySQL, and frequently, hosting providers throttle those processes. I'd like to figure out where the common bottlenecks are and maybe open up some more configuration options to work with different server settings.

  27. WebmistressM
    Member
    Posted 2 years ago #

    Actually its not caused by that change. When I reverted back from the name of my content type to:

    [summarize_posts post_type="post" help="1"]

    ...the memory issue came up again. I can send you the mysql
    Hmm.. I think a few posts back my code did not get formatted in this forum properly

    Even [summarize_posts help="1"] caused the memory error. Just checked my php.ini

    max_execution_time = 120
    max_input_time = 600
    memory_limit = 145M

    By all means, drop me an email address (PM) and Ill send you the my.cnf file

  28. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    The PHP memory is just one part of this... I think you might hit a bottleneck in your MySQL memory.

    The my.cnf has stuff like this:

    key_buffer = 16M
    max_allowed_packet = 50M
    table_cache = 64
    sort_buffer_size = 512K
    net_buffer_length = 8K
    read_buffer_size = 256K
    read_rnd_buffer_size = 512K
    query_cache_limit = 2M
    query_cache_size = 64M
    tmp_table_size = 128M
    max_heap_table_size = 128M

    The SQL query doesn't do anything for me in debugging: the issue arises on your server using your database content, and working within the various layers of memory limits on your server. If the SQL query executes (and you have tested that already), then the query itself is valid. The query is just a string: so long as it is valid MySQL syntax, then it is legitimate, but that's only one small piece of this. Troubleshooting in this case would involve troubleshooting your environment, and that's not something I can do without root access to your server. Make sense?

    The only way I can approximate this is to duplicate your MySQL settings from my.cnf and from php.ini, but that's no guarantee that I'll duplicate the problem because the query performance is dependent on the data set (i.e. your posts and pages).

  29. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    You can use the various WP alternatives here: get_posts() or WP_Query(). If they do the job and don't drive you nuts, then you're good to go.

  30. WebmistressM
    Member
    Posted 2 years ago #

    Yeah. Its a mini tower that I turned into a testing server. Strange to have this come up though as I have had other memory intensive CMS projects and software go into it with no issue.

    Anyhow, I guess your plugin will work better for live servers. Thanks for getting back to me.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic