Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add content to first page of genesis blog page template
- This topic has 17 replies, 3 voices, and was last updated 9 years, 7 months ago by Brad Dalton.
-
AuthorPosts
-
April 14, 2013 at 4:47 am #35352greetMember
I used the "http://dreamwhisperdesigns.com" -tip to add content to the top of my blog page template (http://dreamwhisperdesigns.com/genesis-tutorials/add-content-genesis-blog-page-template/). This works well, but I would like to have this only on the first page and not on the subsequent pages. Any suggestions? Thx
April 15, 2013 at 3:47 pm #35635Brad DaltonParticipantAdd a custom widget to the blog page template.
Can you link to this page on your site please.
You could also add a custom function with a conditional tag.
April 16, 2013 at 2:27 pm #35819greetMemberIn the tutorial the folowing code puts the page content to the top of the blog-page:
add_action('genesis_loop', 'genesis_standard_loop', 8);
How can I extend this to only include this content on the first page and not on subsequent pages.
The link to this page on my site = http://preview.pain-ed.com/public/patient-stories/
Thanks, Greet
April 16, 2013 at 2:52 pm #35824Brad DaltonParticipantAdd a conditional tag:
function add_content_blog_page() { if (is_page('65') ) { echo '<div class="before-blog">Add Your Text or HTML Here</div>'; }}; add_action ('genesis_before_loop', 'add_content_blog_page', 5 );
Replace 65 with the page/post i.d for your blog page or add the conditional tag to your blog page template.
Or there's actually a plugin for this also.
April 17, 2013 at 1:08 am #35901greetMemberBut then the text is not editable ...
What is the name of the plugin? I have been searching without any luck ...Thanks, Greet
April 17, 2013 at 1:30 am #35904Brad DaltonParticipantThis reply has been marked as private.April 17, 2013 at 1:42 am #35905greetMemberThis would be a nice solution for the archive pages since I use genesis, but the pages where I would like to add content to the top of the first page is a 'blog' page and not an archive page.
April 17, 2013 at 2:05 am #35908Brad DaltonParticipantYea sorry greet. Thats why i gave you the code which is the only way unless you use the template. Don't have any other solution.
May 21, 2013 at 5:04 am #42001greetMemberI worked something out(inspired by Brad Dalton's code above) that does what I was looking for. Since I'm just a beginner it might not be the best solution ...I added a page "blog_page.php" to my themes folder with the following code:
<?php
/**
*
* Template Name: Blog
* This file handles blog post listings within a page.
*
*///START add page-content to first page of blogpage
function add_content_blog_page() {
global $paged;
if( $paged < 1 ) {
$page_id = $page->ID;
$page_data = get_page( $page_id );
if($page_data->post_content != ""){
echo '<div class="content-box-blue">';
echo apply_filters('the_content', $page_data->post_content);
echo '</div>';
}
}
};add_action ('genesis_before_loop', 'add_content_blog_page', 5 );
//END add page-content to first page of blogpage
genesis();
May 21, 2013 at 3:46 pm #42083Brad DaltonParticipantThat's another way to do it and not a bad way also. I think you may be able to use the WordPress editor to add content before your posts are listed.
September 20, 2014 at 2:26 pm #125164MichaelMemberHello Everyone-
I am continuing to refine a website at-
I appreciate any help you can give helping me find the error in my code.
For starters, I have followed this thread, which has been a great start and very helpful. I like the way greet's blog looks and was shooting for something similar. After trying several different approaches with no luck, this got me furthest-
<?php /** * * Template Name: MindJock Blog * This file handles blog post listings within a page. * */ //START add page-content to first page of blogpage function add_content_mindjock_blog() { global $paged; if( $paged = 145 ) { $page_id = $page->145; $page_data = get_page( $page_id ); if($page_data->post_content != “”){ echo ‘<div class=”content-box-red”>’; echo apply_filters(‘the_content’, $page_data->post_content); echo ‘</div>’; } } }; add_action (‘genesis_before_loop’, ‘add_content_mindjock_blog’, 5 ); //END add page-content to first page of blogpage genesis();
I have Settings/Reading set to 2, mainly because I only have 3 posts in for now....waiting in more images. If you go to the Blog page, it's displaying them normally. I want to change the display to be horizontal across the page at the blog and there is a part of the code I am missing to get it to do this. The good news is, I have a clue that might help anyone who can help me. That clue is if you click on one of the category links in the blog post, they are displaying like I want them to!
Thank you again for any help you can give!
September 20, 2014 at 3:15 pm #125169Brad DaltonParticipantHi
What exactly do you want to do and on what page?
What you can do is create a custom blog page template if you want to add content before your posts on that page.
September 20, 2014 at 3:35 pm #125170MichaelMemberHi Brad and thanks for chiming in!
I am trying to get the Blog page to display like greet's, who originally started this thread. Here is her blog-
http://www.pain-ed.com/public/
I have several issues and hoping I didn't make too much of a mess with things. Basically, I followed this thread to get this far which included help you had given to greet.
I hope things are a bit more clear this time. I did create the custom blog page template with the code in my first post. (see above) I added in the variable
$paged = 145
which is the ID of the Blog page itself. If you visit the first page of the Blog itself, it still has the old styling- The two posts side by side.http://www.mindjock.com/blog-2/
Interestingly enough, as I am troubleshooting to figure this out, I discovered that if you click one of the "Category" links attached to one of the posts, it is displaying like I want it to.
http://www.mindjock.com/category/sentient-biology/
I will eventually have the post count set to 10 or so, but for now, I have it set at two because I only have 3 blog posts. I am pretty sure I am close and it's a matter of one or two lines of code I am not 100% understanding, as I am learning how to work with these templates and PHP.
I have also been looking for a fix on the red repeating dash image that is supposed to go below each post, but havent figured that out. I have a feeling that once I get the core of the issue fixed here, that will hopefully take care of itself! One step at a time....
September 20, 2014 at 3:53 pm #125172Brad DaltonParticipantHers looks like its a full width layout for the blog page. Can't see any other modifications or am i missing something?
September 20, 2014 at 4:10 pm #125174MichaelMemberNot sure Brad. It looked to me like she has the full width and using the secondary sidebar that hangs outside the content area. The issue for me is I want the blog posts horizontal down the page as she has. I eventually want to add a sidebar to this page but expect the posts to behave the same after that no matter how I format them.
The Balance Theme, which I am using here, comes out of the box with a different blog display than I had ever worked with in StudioPress templates so it has been somewhat of a challenge for me.
Please see-
http://demo.studiopress.com/balance/
See how the very first blog post is oversized? That was the first issue I solved.
Out of the box, it shows the first blog post oversized and the other posts in a grid, sizing them smaller, and in two columns side by side. I didn't want the oversized first post and wanted them all to be stacked on top of each other like in greets blog, not side by side in two columns. I was able to alter the first post image to be the same size as the others, hence no more big first post, but further refinements that I want here have eluded me.
As I said before, the "Category" link, when you click on that, IS displaying the blog how I want it on the first blog page. Please see-
http://www.mindjock.com/category/sentient-biology/
With the exception of the bad positioning of the dashed separator, this is exactly how I want the blog to display on all forms of the blog page. I hope this all makes better sense.
I apologize if I was not clear on that. The only issue there is the red dashed border that is supposed to be below the whole post is kind of sticking to the text for some reason. These are the two issues I am trying to fix.
September 20, 2014 at 5:20 pm #125178Brad DaltonParticipantNot clear to me but hope this helps http://wpsites.net/web-design/add-widget-before-loop-on-first-page-of-custom-blog-page-template-in-genesis/
September 20, 2014 at 6:30 pm #125183MichaelMemberThanks for trying Brad. I had no luck with your solution which was similar to everything I had tried but a different angle using the widget area.
Anyway, I dove in and started deleting grid stuff because that was the main thing that was different from what I have seen in other templates. Line by line I started deleting and finally got what I wanted with the blog display. The red dashed separator is still giving me problems because it is being pushed down the page relative to the amount of text. On blog posts with relatively little text, the separator was up near the end of the text and going through the blog image. I think it's probably a temporary work around but I gave the .content some extra margin and it pushed everything down.....not perfect but workable.
Thanks again.
September 21, 2014 at 9:51 am #125213Brad DaltonParticipantI tested the widget and it only displays on the first page of the blog page.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.