Archived topic
Setting up a blog page
13 replies · Started by Nadia on February 28, 2017
Hi,
I am trying to set up a blog and struggling with a few settings.
1) The blog page is set to a static page. I have customised the blog page with a featured image and also some text to introduce the blog.
The text was done using GP Hooks as follows:
**********************************************8
<?php if ( is_front_page() && is_home() && !is_single() ) : ?>
<header class="entry-header">
<h2>Blog etc etc</h2>
</header>
<?php endif; ?>
****************************
However the problem I have with this is that it shows the text ALSO on single post page. I do not want that...How can this be done please? (I could remove with with CSS display:none but not elegant).
2) The blog page shows all the blog entries with a extract of the first 200 characters. I would like the page to show, for each article, the images included in the article or even videos. How can i do this without using a featured image? (The featured image is used as a header image for the overall design of the site).
Please let me know if you want access to the site, it is still under construction.
Many thanks
Hi Nadia,
1) So basically you want the text to show in front page and blog page only? If so try this instead:
<?php if ( is_front_page() || is_home() ) : ?>
2) WordPress excerpt strips all HTML by default. However you can try using the read more tag:
https://docs.generatepress.com/article/using-the-more-tag/
Let me know if this helps :)
Hi
Thanks for such a quick reply!
1) I tried but still is shows the text on single posts too...
2) Fab!!! this worked :-)
Thanks
Did you check the Execute PHP box?
yes
Hmm the code should work. The condition is only applied if we are on front page (static) or main blog page.
Can you show me the page where it's not working?
Greetings, having a similar issue.
In hooks I have a video on the home page header, the rest of the pages have another simple header, that works fine. But when I add the code in hooks "before header content" as I did for the other pages, it brings up the home page settings. The Execute PHP is checked.
Here's the blog page: http://www.freedomfactor.org/staging/companion
Hooks code:
Home page:
<?php if ( is_page( '17' ) ) : ?>
<img src="http://www.freedomfactor.org/staging/wp-content/uploads/2017/02/header.png" alt="FreedomFactor.org" width="600" height="200" />
<?php endif; ?>
Blog static page:
<?php if ( is_front_page(304) || is_home() ) : ?>
[edsanimate_start entry_animation_type= "fadeIn" entry_delay= "1.0" entry_duration= "3" entry_timing= "linear" exit_animation_type= "" exit_delay= "" exit_duration= "" exit_timing= "" animation_repeat= "1" keep= "yes" animate_on= "load" scroll_offset= "" custom_css_class= ""]
[edsanimate_start entry_animation_type= "fadeIn" entry_delay= "1.5" entry_duration= "3" entry_timing= "linear" exit_animation_type= "" exit_delay= "" exit_duration= "" exit_timing= "" animation_repeat= "1" keep= "yes" animate_on= "load" scroll_offset= "" custom_css_class= ""]
<img src="http://www.freedomfactor.org/staging/wp-content/uploads/2017/02/seal-150x150.png" alt="" width="80" height="80" />
<h3 style="text-align: center; color: #0d4e80; margin-top: -5px;"><em>U.S. Constitution</em></h3>
<p style="text-align: center; font-size: 1.3em; font-weight: 500; margin-top: -27px;color:#fff">Read It, Know It, Share It.</p>
[edsanimate_end]
<?php endif; ?>
Nadia - you can actually use the Blog Page Header feature to add a page header to your blog page only: https://docs.generatepress.com/article/blog-page-header/
Joseph - is_front_page(304) won't work, it doesn't accept any parameters. If you want to target page 304, you would do: is_page(304).
Correct, I tried that too Tom. but somehow it pulls the info from the home page ID 17?
I thought it may be because 304 is a designated post page.
In GPHooks (Before Header Content)
<?php if ( is_page( '304' ) ) : ?>
content here
<?php endif; ?>
Here is the result when I use the above code with the Header checked off on the page.
http://www.freedomfactor.org/staging/companion
Thanks in advance!
Looks like an archive/category page? If so then try is_archive() or is_category().
More info here if you are interested: https://codex.wordpress.org/Conditional_Tags
Hi Tom, Leo,
Ok, I looked into this with a fresh mind today and indeed the Execute PHP was unchecked!!
I was convined it was checked but I moved the code in various places in the hook and probably forgot to check it again.
All is working now, thank you for speedy and great support, as always.
Glad we could help :)
THANK YOU GUYS! Very very helpful!
This post is a bit old.
You can use Displaye Rules instead of conditional tags in Hooks Elements:
https://docs.generatepress.com/article/hooks-element-overview/