Community Forums › Forums › Archived Forums › General Discussion › How do I use a Genesis Theme in my custom code
Tagged: genesis sample, posts, profile page, rendering, template, user post, user posts
- This topic has 3 replies, 2 voices, and was last updated 7 years, 10 months ago by Victor Font.
-
AuthorPosts
-
January 7, 2017 at 6:49 pm #198977patrickrMember
Hi there!
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!
Cheers
http://localJanuary 8, 2017 at 6:56 am #199006Victor FontModeratorThe 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.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet?January 8, 2017 at 7:35 pm #199038patrickrMemberThanks 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.
Cheers
January 9, 2017 at 3:02 pm #199080Victor FontModeratorAll the Genesis loops can be found in the lib/structure/loops.php file.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet? -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.