[Support request] Guidance on Styling Custom PHP Category Page

Home Forums Support [Support request] Guidance on Styling Custom PHP Category Page

Home Forums Support Guidance on Styling Custom PHP Category Page

Viewing 13 posts - 16 through 28 (of 28 total)
  • Author
    Posts
  • #1386017
    Tom
    Lead Developer
    Lead Developer

    Try replacing this:

    echo $content;

    With this:

    echo do_blocks( $content );

    Not 100% sure it’ll work, but should be a step in the right direction..

    #1386078
    Andres

    Hi Tom,

    Thank you for the reply.

    I replaced:

    $page = get_page_by_title( 'Wedding Venues in Costa Rica' );
    $content = apply_filters('the_content', $page->post_content); 
    echo $content;

    with

    $page = get_page_by_title( 'Wedding Venues in Costa Rica' );
    $content = apply_filters('the_content', $page->post_content); 
    echo do_blocks( $content; );

    and it resulted in a “404 There has been a critical error on your website.”

    I’ve left this code in place in case you wanted to review the code.

    What step would you recommend I take next?

    PS: Please confirm you received a gift at your tom…22 email (PayPal transaction ending in 3419).

    I can’t thank you enough for all your help.

    Have a good day.

    Sincerely,

    Andrés

    #1386253
    Tom
    Lead Developer
    Lead Developer

    Sorry about that – just updated the code.

    Thank you so much for the gift! Very generous of you. Always happy to help if I can 🙂

    #1386299
    Andres

    Hi Tom,

    You are most welcome. I very much appreciate all you’ve done and continue to do.

    On a side note, I Vancouver Island listed as the location on WPSP. I actually spent a bit of time north of there at Whistler Blackcomb. What gorgeous mountains.

    I used:

    $page = get_page_by_title( 'Wedding Venues in Costa Rica' );
    $content = apply_filters('the_content', $page->post_content); 
    echo do_blocks( $content );

    , and the content is now appearing. The formatting/styling, however, has not changed.

    Whenever you have time, please let me know what you think I should try next.

    Cheers, Tom.

    Andrés

    #1387145
    Tom
    Lead Developer
    Lead Developer

    Awesome! Leo in the forums here lives up in Whistler 🙂

    That’s a shame – I was hoping this method would work. One last thing to try would be to turn on Inline Embedding as the CSS print method in “Settings > GenerateBlocks”.

    If that doesn’t work, this method may not be compatible with Gutenberg as it is right now, unfortunately.

    #1387206
    Andres

    Hi Tom,

    I went there in the summer for a snowboarding camp on the glacier. It’s simply breathtaking there. I spent a lot of time on the mountains in Lake Tahoe, and went I went to Whistler, I was in awe. The only thing Tahoe has no Whistler is the lake.

    Thanks for getting back to me so soon.

    The Print Method in GenerateBlocks was already set to Inline Embedding. I set it to External File and cleared regenerate the CSS cache to see if that would work, and it did not. Neither worked.

    That’s too bad. We were almost there.

    In your first response to this support ticket, you mentioned 2 possible ways to do this: 1. the one we’ve tried, and 2: “build the custom category template and add your content in there.”

    I already have the category template built (category-costa-rica-wedding-venues.php). How would I add the content to it so that it looks like this page: https://wordpress-424710-1336702.cloudwaysapps.com/venues/

    I have another question about another possible method.

    While working on the first method, I created a 2-column, 3-row table in the Description field of a category page. I was able to replicate the page https://wordpress-424710-1336702.cloudwaysapps.com/venues/ on desktop. On mobile, however, the styling was all off.

    Would it be possible to style a table in a category’s Description field so that it renders how I want on mobile?

    #1387433
    Tom
    Lead Developer
    Lead Developer

    Using the second method wouldn’t allow for blocks to be used, either.

    Is it necessary to use a category template here? Couldn’t you build it as a static page?

    #1387446
    Andres

    Hi Tom,

    Thanks for letting me know putting the content in the custom category template is not possible.

    Did you have a take on the other possibility I mentioned that of using a Table in the Description field in the category page itself (Posts > Categories >; Category in Questions > Description? I was able to have the content the way I wanted doing this. It looks fine on desktop. On mobile, however, the styling is off.

    Is it possible to style the content that’s in the Description field in a category page (not the custom category page)?

    If this is not possible, then yes, I can use a static page. The only concern is the taxonomy for breadcrumbs.

    I don’t know if it’s possible to have the static page be part of the breadcrumbs chain: Static Page > Category Page (with posts list) > Post

    Costa Rica Wedding Venues (static page) > Luxury Venues or Unique Venues (category page + WPSP Posts List) > Post

    That’s the only reason I was trying to get the category page to work.

    What is your opinion. Do you think it’s possible to use the static page in place of the parent category page (the problematic custom template page) and have the breadcrumbs this way?

    Cheers!

    Andrés

    #1388411
    Tom
    Lead Developer
    Lead Developer

    It may be possible, but it’s likely you’ll run into hurdles. Archive pages in WordPress really aren’t meant for static content. GeneratePress 3.0 might make this easier, as we’ve introduced some new hooks.

    As for breadcrumbs, I’m not sure, unfortunately. You’d have to check with the developers of the breadcrumbs to see if you can control their display – it’s likely possible with a filter 🙂

    #1388519
    Andres

    Hi Tom,

    Thanks. This was the last thing to do to have the site ready for launch. The thing I thought wouldn’t be much bother turned out to be the biggest PITA.

    From what I gather, pulling formatted content from a static page onto a category page is not some wild, rare, esoteric undertaking, so that it’s not working out is quite odd and disappointing.

    I’ve contacted Yoast about somehow having the static page replace the category page in the breadcrumbs chain.

    I’ve also contacted Gutenberg regarding not being able to pull the formatting given your comment that the issue might be with Gutenberg.

    I have a question about a document on WPSP that might be a solution: https://docs.wpshowposts.com/article/use-static-pages-as-category-archives/

    This does work. I tried it this morning. The only issue is that I would have to create a static page for all the category pages I’ve already created (plus their corresponding custom category templates) and styling. To have to redo all of them is not feasible.

    Is there any way to modify that code so that it targets only one category page instead of all of them?

    I’ll let you know what I find out from Yoast and Gutenberg.

    Have a good day.

    Cheers!

    Andrés

    #1388667
    Tom
    Lead Developer
    Lead Developer

    It’s a tough one, as it goes against how WordPress works by default.

    Yoast should be able to help with their breadcrumb feature. The issue itself isn’t a Gutenberg issue, it’s more of a WordPress issue with how archives work.

    As for that solution, this code may work better: https://wpshowposts.com/support/topic/filtering-category-views-to-showpost-pages/#post-10663

    #1388727
    Andres

    Hi Tom,

    Thanks for the reply.

    Regarding code on https://wpshowposts.com/support/topic/filtering-category-views-to-showpost-pages/#post-10663, is it possible to modify it to just target one category page instead of all of them?

    I’m not sure what you meant by: “As for that solution, this code may work better:”

    Have a good day, Tom!

    Andrés

    #1389687
    Tom
    Lead Developer
    Lead Developer

    That code will only work if there’s a page name with the same name as the category being viewed. So as long as you don’t have matching names, it shouldn’t do anything to those other categories.

Viewing 13 posts - 16 through 28 (of 28 total)
  • You must be logged in to reply to this topic.