Site logo

[Resolved] Setting up a blog page

Home Forums Support [Resolved] Setting up a blog page

Home Forums Support Setting up a blog page

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #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

    #285238
    Leo
    Staff
    Customer Support

    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 🙂

    #285244
    Nadia

    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

    #285247
    Leo
    Staff
    Customer Support

    Did you check the Execute PHP box?

    #285249
    Nadia

    yes

    #285251
    Leo
    Staff
    Customer Support

    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?

    #285364
    Joseph

    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; ?>
    #285365
    Tom
    Lead Developer
    Lead Developer

    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).

    #285408
    Joseph

    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!

    #285410
    Leo
    Staff
    Customer Support

    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

    #285531
    Nadia

    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.

    #285595
    Leo
    Staff
    Customer Support

    Glad we could help 🙂

    #915517
    Alban

    THANK YOU GUYS! Very very helpful!

    #915562
    Leo
    Staff
    Customer Support

    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/

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘Setting up a blog page’ is closed to new replies.