Home Forums Modern Using Custom Post Types instead of Standard Posts

Viewing 5 posts - 11 through 15 (of 15 total)
  • Author
    Posts
  • #21613

    Sharkster4000
    Participant

    Hi Oliver,

    as said before, everything works now. Thanks again! I only have one last issue that I failed to resolve. The categories show up on the blog posts as intended, but not on the timeline items. Neither in list-view, nor in full view. I’ve attached a screenshot to show the difference between blog posts display and timeline items display.

    Any idea what prevents the timeline items from showing the categories like the blog posts do?

    EDIT: Please note that I removed the post date/time from the meta info via CSS intentionally.

    #21615

    Oliver Juhas
    Keymaster

    Hi Martin,

    You can go 2 ways about it.

    1. Since you are already overriding the whole post meta file in your child theme, simply add your custom post type to array (so it becomes array( 'post', 'cool_timeline' )).
    2. Or, as you can see, there is a filter applied to edit the array. So, just add an appropriate code to your child theme‘s functions.php file to modify the array via wmhook_modern_entry_meta_post_type filter hook:
      function child_theme_entry_meta_post_type( $post_types ) {
      	$post_types[] = 'cool_timeline';
      	return $post_types;
      }
      add_filter( 'wmhook_modern_entry_meta_post_type', 'child_theme_entry_meta_post_type' );

      (This is more flexible way, which applies the change everywhere in the theme.)

    Use whichever procedure feels easier to you.

    Tip: The theme supports Jetpack plugin’s Content Options to switch post meta easily via customizer.

    Best regards,

    Oliver Juhas
    WebMan Design

    #21624

    Sharkster4000
    Participant

    Hi Oliver,

    thanks again! I went for method 2, as I want it to be shown throughout the entire site. Works like a charm…! :)

    But I now saw that they’ve added an own taxonomy for their “categories” (they left the visible definition “categories” the same as the “categories” for blog posts, which is why I haven’t noticed this before). Can you help me show their taxonomy (aka “timeline item categories”) instead of “blog post categories”?

    I guess I’ll have to add their “timeline item categories” to the list of meta info types displayed and remove the real “blog post categories”?

    Best regards,
    Martin

    #21625

    Oliver Juhas
    Keymaster

    Hi Martin,

    Please understand that these modifications are out of scope of the support service provided (read the terms of service). Please try to hire a developer to help you modify the theme.

    Here is a short instructions on how you can introduce custom post meta:

    1. In your child theme create a new file template-parts/meta/entry-meta-element-timeline-category.php.
    2. You can copy the code from modern/template-parts/meta/entry-meta-element-category.php file into your new file and ask your timeline plugin developer/support for help on displaying the timeline categories.
    3. In your child theme‘s template-parts/meta/entry-meta-bottom.php file (you’ve copied and modified already before) you can then add a code like:
      if ( 'cool_timeline' === get_post_type( get_the_ID ) ) {
      	get_template_part( 'template-parts/meta/entry-meta-element', 'timeline-category' );
      }

    Again, please adapt the code to your needs.

    Tip: You can have a look at WordPress developer handbook for help with WordPress related code. Conditional tags reference is also available in theme development handbook.

    Best regards,

    Oliver Juhas
    WebMan Design

    #21626

    Sharkster4000
    Participant

    Hi Oliver,

    thanks for the quick reply (as always!). I didn’t know it was such a complex thing to achieve. Being the PHP-n00b I am, it’s kinda hard for me to estimate the effort it takes for specific changes. I wouldn’t have been surprised if it was just changing a single line of code… or re-writing the entire theme lol.

    Turns out it’s closer to the latter.

    I’ll reach out to the plugin author and ask for his help on this. Anyway, thank you for your professional assistance and for pointing directions with this!

    Best regards,
    Martin

Viewing 5 posts - 11 through 15 (of 15 total)

You must be logged in to reply to this topic.