- This topic has 13 replies, 5 voices, and was last updated 6 years, 10 months ago by
Leo.
-
AuthorPosts
-
February 28, 2017 at 12:04 pm #285227
Nadia
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
February 28, 2017 at 12:14 pm #285238Leo
StaffCustomer SupportHi 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 🙂
February 28, 2017 at 12:23 pm #285244Nadia
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
February 28, 2017 at 12:26 pm #285247Leo
StaffCustomer SupportDid you check the Execute PHP box?
February 28, 2017 at 12:33 pm #285249Nadia
yes
February 28, 2017 at 12:35 pm #285251Leo
StaffCustomer SupportHmm 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?
February 28, 2017 at 3:56 pm #285364Joseph
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/companionHooks 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; ?>February 28, 2017 at 3:59 pm #285365Tom
Lead DeveloperLead DeveloperNadia – 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).February 28, 2017 at 6:45 pm #285408Joseph
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/companionThanks in advance!
February 28, 2017 at 6:53 pm #285410Leo
StaffCustomer SupportLooks like an archive/category page? If so then try
is_archive()oris_category().More info here if you are interested: https://codex.wordpress.org/Conditional_Tags
March 1, 2017 at 3:24 am #285531Nadia
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.
March 1, 2017 at 5:57 am #285595Leo
StaffCustomer SupportGlad we could help 🙂
May 30, 2019 at 9:19 am #915517Alban
THANK YOU GUYS! Very very helpful!
May 30, 2019 at 10:21 am #915562Leo
StaffCustomer SupportThis 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/ -
AuthorPosts
- The topic ‘Setting up a blog page’ is closed to new replies.