Dynamic Content (some feature requests & questions)

I’ve been building out a new site using the beta, and have come across some use cases I’d like to address. I can address many of these with custom code, but they also feel soooo close to functionality you guys are building that I figured I might as well mention them.

––

Maybe for this release:

Categories & Tags
We touched on this a few weeks ago in a prior thread, but will there be Categories/Tags in DC? And how is that going to work with hyperlinks? Most times, I’ll personally want to output links, but I can imagine some other times when I might just want text displayed (in some archive contexts).

Author Permalink
Maybe I’m missing something, but I can’t find a way to use DC to insert links to either the author archive or the website listed in the author’s profile (since the “user meta dropdown” isn’t working in Beta5, I looked through the options in the prior release version – and while I see options for the Instagram or LinkedIn urls, I don’t see any options for website)

  • The use case here is that I’m building an author element using the layout builder, and I want to be able to link to their bio page on the site. For some clients that’d be just the author archive, but for others I might have a more custom “about” page, which I’d just add to their profile.

Post Type
Is there a way to pull post type with DC?

  • The use case is that I’m building a new search results page, and I want to show whether something is a Page, Post, Location, Staff, How To Guide, etc. – many of those based on CPT.

I know I can do conditions based on post type, so I can always create a bunch of elements with conditions applied to them (similar to the woo badges in the starter templates). However, there are times when all that’s needed is a simple piece of text.

  • Another way I was thinking about possibly using this is within the URL for an image element. For example, url.co/wp-content/{{dc:post-type}}.jpg and having corresponding file names for those. I could make the names simple enough so I wouldn’t run into spacing conflicts, but it might be useful to have an advanced option where you can reference the slug for the CPTs too.

––

For a future release:

Math in Dynamic Content & Conditions
@Misho mentioned some math functions in the conditions thread, and I’d love to be able to easily run calculations on dynamic content fields too. Here are a couple use-cases.

  • To show sale amount on products. For example, when a product is on sale, display a “Save $10” or “Save 23%” badge etc.
    Save $10.00
  • To take Misho’s example a little further, when close to a promotional threshold – show exactly how far they are away from it. For example, “You’re only $13.00 away from free shipping”, etc.
  • Another example would be to compare two products’ prices. “Save $15 compared to option B”, etc.
  • Another use case is comparing two dates. “Article posted 2 days ago”, etc.
  • Another is a simple reading time calculation. People have different ways of calculating this, but the simplest is usually something like `(word count) / (200 words per minute)’. I did this on one site using functions.php, but native functionality would be sweeeeet.
    • I guess this particular one would also require a DC option for word count too, but I think there’s a function for that somewhere within WP core…
3 Likes

Post Format
Similar to my examples above for Post Type, I was hoping to do something similar with the different Post Formats.

image

However, I don’t currently see either dynamic content for those settings. (Edit: For whatever reason, I wasn’t seeing the “Format” option in the conditions dropdown, but I now see that as an option for conditions)

  • For example, in the archive views, I’d like to use different labels or icons for Standard posts vs Video vs Quote, etc.
  • Additionally, for the posts themselves, I’d like to be able to do things like display the video element – but only on Video posts.
    • I guess all those special formats get tricky though, don’t they? The video one alone has 4 different settings you can combine when adding a video…
    • I’ve been wondering about whether we’d someday be able to use DC as fallback for other DC, and I guess this might be a use case for that… but my goodness this gets complicated quickly :hushed:

Hi @devinelston,

Confirming receipt of this as well. Working on clearing a wave of bugs and I’ll be back to discuss this as soon as I can. Thanks for your patience, and for continuing to bring awesome feedback like this throughout the process. Talk soon.

1 Like

No rush. Squash those bugs!

Life in software development :rofl:

2 Likes

:rofl: hahaha! I can relate! We’re getting really close. This is a monster update in terms of things that we wrote, rewrote, and new things developed but coming into the middle of this week I think we’re turning a corner. Might need one more beta before we do a release candidate. We’re getting really excited about getting this out!

1 Like

I’m excited about it too! I was about to go rogue and put it on a live site… but ran into that issue where I can’t download the template I built on a staging site to move it over to a live one. So that particular bug probably helped me out :nerd_face:

Close one! :smiley:

Quick followup here:

  • Template downloading bug is fixed
  • Dynamic Content added for
    • Taxonomies. There’s a “Current Post Terms” looper provider and a Term section in Dynamic Content
    • Author. Carbon copy of the User items but configured to use the post author by default instead of the current user
    • Post Types. Singular and Plural names, plus the archive URL are now exposed
  • You can hide/show elements based on the post format of the current post.

I think we’ll need to do another update with some focus around conditional logic in general, so that would be a good time to revisit potentially doing calculations in there.

Awesome, thanks!

:+1: You’re welcome!

@alexander, I’m still going through it all, but so far I’m liking the new looper options for tags/categories, and the DC for post types. Good stuff :+1:

However, for the author meta… I cannot figure out how to get the author URL. In the dropdown for author meta, there isn’t an option for URL – and even entering it as a custom key doesn’t do anything. All sorts of other values registered by Yoast show up (e.g. Facebook, Instagram, etc.). What am I missing?

Hey, looks like we’re missing one for get_author_posts_url. I’ve added that for the next patch.

Awesome, thanks!

You’re welcome!

@alexander, I’m just circling back to this one. The author_posts_url is great, however there’s another author-related URL I think should be an option. The “website” users can list in their profiles.

image

I’m pretty sure it’s a default option in the user profile, but I can’t figure out how to pull this one through – it doesn’t show up in the DC dropdown, and it didn’t work with a variety of custom keys I tried.

Am I missing something on that? Or can we get that added as well?

Should be able to pull it through with user_url as the key for a user meta field. But it does feel like something we should just have (along with bio) since those are WordPress native profile fields and we have the others. I was able to quickly alias them for the next patch.

1 Like

Perfecto, thanks!

I have a CPT with a taxonomy of “job_title” and it seems that it will not bring it in (the subtitle and button are not populated dynamically), although it looks like you can show the category title for regular posts (my posts section and image worked fine) but it is not working for Custom Post types?

The first section has a looper provider:

Then the row has a looper provider of current post terms. and the column is set to consumer.

My current workaround is to use ACF and add a select field on the CPT. I can then add the field id in dynamically and it will populate the content. Not ideal since I’d rather use the taxonomy.

Hi @designerken,

Inside that Post somewhere, try adding Looper Provider on an element and set it to “Current Post Terms”. This will let you loop over a taxonomy associated with your post. There isn’t a way to pull just one like you’re doing there since it doesn’t know what the term data is at that point.

::SOLVED::

I added a nested row and the looper to that so the column could consume the data.

  1. Section 1 - Sets the query
  2. Row 1 - Does nothing but set up the flexbox for its elements
  3. Column 1 - Consumes data from section (3 in this case)
  4. Nested Row 1 - Looper Provider of Current Post Terms (Job Titles)
  5. Nested Column 1 - Looper Consumer (for Job Titles) and container for all elements