Total newbie - struggling posts by current

hi there

i am creating posts and assigning them to different accounts.
I am hoping to create a few pages which are then able to serve dynamic content by current user

i.e if they click on ‘updates’ they will see a list of updates that I have created and assigned to their account. another user would see a different set. I have normal posts and cpts.

I am sure this is do’able with L&L but honestly, I really struggle with maths, coding, algebra, basically anything useful. So I am now residing to the fact that I ned help here. I’ve built a great site but it doesn’t work yet because it isnt dynamic, I really need this to work, for both my sanity and my future business ha ha.

Please could someone lend a hand? I dont know how I can help you in return but I would happily try!

Hey Gary, welcome to the forum! Luckily for you, L&L doesn’t require you to know any math/coding/algebra to do most of the things it can do and it should be quite easy to display the kind of data you’re looking for. If you’re struggling with getting started, I’d recommend checking out some of the “best practices” blog posts, specifically the “absolute beginner’s guide.” You might find some valuable guidance in there that could help you get comfortable with L&L. I’m currently working on bringing a lot of that info over to the documentation but for now those blog posts are solid resource to help you get comfortable with the basics.

I’d be happy to give you some pointers for your particular site, but you’ll need to elaborate some more about what your different post types are called, how you’re associating update posts with users (maybe an ACF relationship field?), and how you’re hoping to display the content/fields of your update posts. If you can provide more info on the names/types of posts and field you’re using, I’d be happy to help you out.

1 Like

Edited to remove URL:
hey Benjamin, thanks so much.

I will take a dig into the blog posts.

So here’s what’s what.

I have a number of years experience working in music in both management, distribution and at major/indie labels. They all have a particular set of challenges. My site ostensibly serves as a platform to house my clients, but also to provide non clients a place to utilise a few tools.

What i’ve done:-

Create various CPTS but assign them with core taxonomies (Updates, Campaigns, Agreements, Assets, Tools, Releases etc)
Create matching categories
Create a couple of user accounts
Create tags for the aforementioned cpts, in line with the user account names
Create a number of pages (Client HQ, Campaigns, Agreements etc)

My thought process:

Create new post/cpt as necessary - let’s say Agreements, tag with user user account name
Change author to user
Create loop on relevant page which pulls in any agrement cpt, by current userid/logged in

I’m attempting to use UserWP too.

I’ll be honest: I have not worked out how to add code to a template yet, so bare with.

I’m still a little unclear about your data structure, but I understand your goals a lot better based on your description here. I might be wrong, but a few of the things you’ve mentioned, like “Change author to user,” suggests that you might not be familiar with creating custom fields yet which is a pretty fundamental concept when you’re working with WordPress. If that’s the case, then I’d recommend doing some more general research into adding custom fields to your post types (both CPTs and core post types like users). L&L is really powerful when I comes to displaying your data, but getting a good underlying data structure that makes sense is the first. Doing things like assigning a post to a user using the author field might be a bit limiting for you long-term and a better way to approach this might be to use ACF to add a user field to the CPTs you’ve made, which could allow you to associate a post with multiple users (your author approach would only allow you to associate a post with one user and isn’t really the way that author field is designed to work anyway). Once you’ve done that, you could use L&L to build a page (e.g. a page that shows a user their agreements) that loops through all the posts that have that user listed in the ACF user field you would have made. If you go for that approach, your template might look something like:

<Loop type=agreement field=my_acf_user_field field_compare=includes field_value="{User id}">
  <If field=title exists>
    <Field title />

That’s also not necessarily the most efficient way to write that, but I thought I’d split that into an If tag and a Loop tag so you could see a bit more clearly what’s going on. Play around with displaying simpler stuff for starters by following along with those blog posts I pointed you to and as you learn your way around and look through the docs this should eventually make sense. Don’t worry if it doesn’t make sense right now as you’re just getting started! There are lots of different ways to approach this, but figuring out how you’re going to structure your data in a convenient/logical/flexible way is step one before you start using L&L to display that data.

Thanks Benjamin, it’s actually really useful for me to just even be able to have this conversation, thank you again!

The data structure isn’t really a structure ha ha. Ostensibly, I am creating posts from the admin panel and then assigning them by changing the author!

I have ACF installed and I have created some field groups in order to apply a CPT; here’s one for example.

i have now added the user field. If this is what you mean as per the screen shot (but with User/user_field) added, I will add it to the rest of my posts!!!

Nice! You’re on the right track. And yeah, using “smart” ACF fields like “user” or “relationship” is almost always better than using text fields. Once you get to the point in your site configuration and your understanding of L&L where the markup I wrote above makes sense to you and you’re able to adapt it to your needs, you may want to look into this syntax. It’s a bit more advanced in that it relies on you having a good understanding of both the If tag and the Loop tag, but it’s the syntax I’d probably use in your case since it’s more efficient/versatile.

Also, out of curiosity, how did you come across L&L? I find most people who discover it already have a site set up with a complex data structure, but it seems you discovered L&L earlier than most in your WordPress journey. I’d be curious to know how you heard about us!

1 Like

I got to it via the page of a plugin that you made but retired in favour of this. But I can’t remember it’s name!



working on tihs…

OK Yep I’'m really struggling here.

My assumption was

<Loop type=posts field=user_field field_compare=includes field_value=“{User id}”>
  <If field=user_field exists>
    <Field title />

then I inserted the saved template via the block editor to the currently non dynamic page that housed the posts, then I changed the post query loop to display ALL posts.

under the user account it didnt filter it.

Am I getting close here?

I have somehow ended up here…

acf user field set to return id.

<Loop afc_post=alter_updates field=user_field field_compare=includes field_value=“{User id}”>
  <If field=id >
    <Field title />

But I think i may have strayed from the path...

I’m now at this.

 <Loop type=alter_updates field=user_field>
  <If field=current exists>
    <Field title />

I’m going round in er… loops, lol

Ok I took a look at your markup and I discovered part of the problem. It’s annoyingly simple: when I responded to this thread this morning I was on my iPhone, which changed these quotes " " into these quotes “ ”. The latter isn’t actually the right kind of quote that works with HTML/L&L so I think that’s what was messing that tag up. I’ve gone back and corrected my earlier post to use the correct characters. Sorry that the thing that caused some of your issues here was iOS’s styles quotation marks haha!

A few notes about the things you’ve tried:

type=posts probably isn’t a valid loop type on your site. It sounds like you’re trying to loop through all your post types at once, but what you’ve actually written with this is that you want to loop through all posts within a single post type that’s called “posts.” The default blog post type in WordPress uses the slug post but I don’t think you were trying to loop through your blog posts when you wrote this. It’s pretty easy to loop through all your post types and then loop through the posts from each post type by nesting one loop inside another, but I’d recommend just trying to display data from one post type. Start with something simple and work up from there once you’ve figure that out.

Here you seem to have invented a new attribute (afc_post) that isn’t anywhere in the documentation. I’d recommend sticking to tags and attributes that exist :wink:

I think you should really just go back to the blog posts I linked to. Start with the absolute beginner’s guide, then learn the terminology and syntax so that you can understand the documentation a bit better, and then once you’ve successfully started figuring out how to use the Loop and Field tags to display data from different kinds of posts, check out this article about the Loop tag to get a better understanding of that. The markup examples you’ve shown seem to show that you’re trying things at random without understanding what they do. Keep it simple while you’re learning and then work your way up.

You seem to have a good curiosity and willingness to tinker, so I think you’ll get there eventually, but I think part of your issue right now is that you’re using tags and attributes without knowing what they do or what the correct syntax is.

I know the current documentation is a bit sparse on explanations, so here’s a sneak preview just for you: a link to a draft version of our new documentation site. Most of the links are broken or go to the old docs site, but if you navigate using the left-hand menu, you’ll notice that this site has some easier-to-digest onboarding material which borrows a lot from the blog posts I linked to earlier as well as better-documented pages for the Loop and If tags and some example templates. I’m still working on it so don’t expect everything to look/work right just yet (should be done in the next week or two), but those new docs might be better for someone like you who’s just beginning. We’ll also be producing some more explanatory/video content in the near future so keep an eye out for that on the blog/forum in the coming weeks/months.

1 Like