Support » Plugin: Custom Content Type Manager » [Plugin: Custom Content Type Manager] Looping query and grouping by custom field?

  • My old website was in drupal, you can see my “tech article” list here I’m trying to recreated this in wordpress. I have your plugin installed, and I’ve imported all my content. I’ve spent the last 4-5 hours working with [summarize-posts] to try and get it working.

    Using this code [summarize-posts post_type="tech_article" orderby="post_title" order="ASC" 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"]<li>([+categories+]) <A href="[+permalink+]" title="[+post_title+]">[+post_title+]</a>([+post_tag+])</li>[/summarize-posts]
    I get this page as a result which is a start.

    The problem is that I want it to list the Category above the posts, not next to each one, so I need to do a while loop, but I don’t know if I can via short code. If you look closely, you can see that your custom field is storing it as

    [“Misc, Things Not In Other Categories”]

    when I believe it would work better as

    Misc, Things Not In Other Categories

    . I realize the quotes are because of the comma, but they should be stripped out on display. I also can’t filter by the category if it contains quotes in it.

    Can you help me with the proper code to recreate my old page? Should I move away from using your custom field for Category and use the built in Category function?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor fireproofsocks


    Categories are stored as an array — it’s not a simple topic, I’m afraid. If you want to geek out, you can read about all the considerations for this here: The quotes are not there because of the comma — Categories is a list of values, i.e. and array, so the CCTM stores the values as a JSON encoded array.

    You should not need to use the “join_rule”, and you should not need to verbosely specify the “omit_post_type” or the “date_column” — those fields will use sensible defaults, so you can simplify your short-code there a lot.

    You can do this via short-code in versino (currently in dev, but it is stable), but I don’t have much documentation for that yet. Otherwise, I would recommend you do this inside the theme file using the equivalent PHP. The you can use the php functions like json_decode() to convert the JSON arrays to PHP arrays and iterate over the values.

    This is a little over my head. Is there a filter I can add to your short code to only pull certain categories? I can do something like this then.

    Cat 1
    [shortcode cat=1]
    Cat 2
    [shortcode cat=2]
    Cat 3
    [shortcode cat=3]

    So that any time I add content to those categories it updates? Do I need to change from using your field from categories to using the built in taxonomy for this? I’d perfer to use the built in taxonomy really, I just didn’t see the option originally when I set up the new content type, but now that I know it’s there, I’d like to use that.

    I got it taxonomy=category taxonomy_term=Steering

    I’ll use this and my shortcode idea above, thank you. This isn’t automated, and if I add new categories, I’ll have to add them here too. Is there a better way to do this utilizing your code?

    Plugin Contributor fireproofsocks


    Yes, you can use a shortcode like that… just list the taxonomy and the taxonomy_term, e.g.

    [summarize-posts taxonomy="category" taxonomy_term="Steering"]

    Don’t forget the double-quotes.

    Plugin Contributor fireproofsocks


    If I were you, I’d create a dedicated page for this and then use a dedicated template file — that way you could do all of this in PHP, which will be far more flexible than the shortcode.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: Custom Content Type Manager] Looping query and grouping by custom field?’ is closed to new replies.