Site logo

[Support request] Custom Post Type in Block Element

Home Forums Support [Support request] Custom Post Type in Block Element

Home Forums Support Custom Post Type in Block Element

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2445406
    Martin

    Trouble with accessing Toolset custom post type ‘article’ in block element. My custom fields have been defined with Toolset Types.
    —————-
    What I’m trying to do (I’m exploring converting my site to use GP premium and GB replacing Toolset views):
    – replicate my site at mr.math.ca for ‘article’ cpt to create an article archive for displaying search results and also single post content template (similar to mr.math.ca/article )
    —————–
    what I tried:
    1. to recreate my archive, I used GP block element with type loop template –
    a) added a GB Query block and put GB paragraph blocks in the Post Template Block (inside the GB query Loop block)
    What happened:
    – using the GB query loop block seemed to give multiple copies of one post so I deleted the query block and just used paragraph blocks
    – after deleting query block, for each paragraph block, Post Source was set to the first article (could not set it to a post type? – thought I was in a loop not specific posts?)
    – when a specific article was selected as post source, I could select Source as ‘Article meta’ and then see the Toolset custom fields I wanted.
    – on the front end article archive, only the one article displayed. No loop of all articles.
    – also the fields displayed concatenated on the same line although I would have expected them on separate lines?

    2. to recreate my single post content template, I used GP block element with type content template – did not see how to show the toolset cp fields?
    in GP element template: Type=Content Template, Tag Name= article (my slug for cpt), Apply to: Posts with custom field, Post meta name= article (slug from Toolset setup…)
    what happened:
    – GB Headline block did not show the custom fields from my ‘article’ cpt in the Dynamic dropdown menu of the Headline block?
    – GB Headline block in right hand dynamic data meta (not the block dropdown) did not have option for accessing my custom post type with the custom fields?
    – on front end, my GP content element did not seem to replace the one previously setup in Toolset content templates by Toolset views plugin? Do I need to register this somehow?
    – also, not clear on when / why to use the GP Dynamic custom content block? It seems to only access Pages and Posts but not cpt’s?

    3. I don’t understand when to use the GB query loop block. When I tried it in the GP element loop template assigned to my ‘article’ archive it gave me multiple copies of a single custom post. So clearly I should not use it in an archive since that is already using the core query. So when would I want to use it…eg. could I create a query of my custom post type (article) to show titles and custom fields of my featured articles, and place that on my static home page?

    4. Should I buy the GB Pro to do what I need here? not sure if I need it?

    ————–

    Sorry to have so many questions, I am trying to use the forum and documentation but so far I don’t see answers for what I’m trying to do.

    #2446122
    Fernando
    Customer Support

    Hi Martin,

    1. – 3. The Block Element – Loop Template needs a GB Query Loop Block to show the loop.

    It shouldn’t be showing duplicate posts though. What was your exact structure? There may be something wrong with it that caused the issue.

    could I create a query of my custom post type (article) to show titles and custom fields of my featured articles, and place that on my static home page?

    Yes, you could do this.

    The Query Loop can be used on a static page or dynamically in an archive/blog page through a Block Element – Loop Template: https://docs.generatepress.com/article/block-element-loop-template/

    You can also use a Block Element – Content template for the blog/archive pages. Reference: https://docs.generatepress.com/article/block-element-content-template/

    2.
    a. The Post meta field could only appear if it’s set to Show in the REST API by your plugin. Check this video out by Jean: https://www.youtube.com/watch?v=tnZZps-ef5Q

    If it’s not appearing, you can also manually type it there. That should also work.

    b. If you’re trying to show the article meta dynamically per post through an Element, the Data source should be Current Post: https://share.getcloudapp.com/xQuOv4qd

    c-d. I believe you don’t need a Block Element – Content Template. Rather, just a Block Element – Hook. Can you try this instead? This should work for CPTs.

    4. No, you shouldn’t need GB Pro to achieve these. The GB free version should be good enough.

    #2447354
    Martin

    Looks like my site uses toolset repeating fields for author(s) of articles. Any idea when that feature will be available with GenerateBlocks and GeneratePress?

    Otherwise, everything is looking good.

    #2449573
    Fernando
    Customer Support

    I see. Support for repeater content fields is already planned as a future feature for GB Pro but there’s no timetable yet. For now, you would need custom code to inject it properly in a Query Loop Block.

    Glad everything is looking good now though!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.