January 7, 2017 at 6:49 pm #198977patrickrMember
I'm new to the Genesis Framework and WordPress. I'm trying to understand how to use my Genesis Sample's post template in my custom code.
For example, I'm creating a profile page where logged in users can see all of their blog posts, plus access some profile settings. Getting the user's posts is pretty straightforward:
$user_id = get_current_user_id(); $args = array('author' => $user_id); $posts = get_posts( $args );
Now that I have an array of posts contained within
$posts, I need to loop through and render them. This is the part I'm unsure of; what does that loop look like so that the posts on the profile page render the same way the posts on the homepage of the Genesis Sample theme render?
A code snippet would be really helpful, but also pointing me in the right direction, in terms of documentation or digging through the theme's source code, so that I can teach myself, would be appreciated. Thanks so much!
Cheershttp://localJanuary 8, 2017 at 6:56 am #199006Victor FontModerator
The Genesis Sample theme doesn't have a custom post_template. It uses the post template from the framework. You should never modify any framework file. You will eventually break your site and lose your work.
If you want a custom loop, you don't even need a custom post template. All you have to do is create your loop in functions.php, remove the standard loop action and hook your new function into the loop. This is one way to do it: http://www.genesissnippets.com/2012/09/15/genesis-custom-loop/.
If you Google Genesis Custom Loop, you find there are many ways to do what you want.
January 8, 2017 at 7:35 pm #199038patrickrMember
Thanks for the reply, Victor. I took a look at the link, and I understand I need to create a custom loop, but what I don't understand is what that loop should look like to get the same design as the blog posts on the homepage. The workflow is something like:
Get logged in user's posts -> Pass the posts to the custom loop
I have the logged in user's posts. How do I pass them to the loop in the form of a variable and what does that loop look like?
The latter is probably as straightforward as finding the loop that renders the posts on the homepage, and copy/pasting it into the functions.php file, with a tweak for it to accept the variable containing the posts.
CheersJanuary 9, 2017 at 3:02 pm #199080
- The forum ‘General Discussion’ is closed to new topics and replies.