MINIMUM Theme: Adding the post and page title to page-title.php

Community Forums Forums Design Tips and Tricks MINIMUM Theme: Adding the post and page title to page-title.php

This topic is: not resolved

This topic contains 5 replies, has 3 voices, and was last updated by  emke 1 year, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #14049

    Jones
    Participant
    Post count: 5

    Hi, When opening posts and pages I want to echo the title of that page inside page-title area. Now it displays the description only.

    this is what it is now:

    elseif ( is_singular( 'page' ) ) {
    echo '<div id="page-title"><div class="wrap"><p>' . esc_html( get_bloginfo( 'description' ) ) . '<a class="page-title-button" href="#">' . __( 'Subscribe Now', 'minimum' ) . '</a></p></div></div>';

    thanks in advance

    • This topic was modified 1 year, 7 months ago by  Jones.
    • This topic was modified 1 year, 7 months ago by  Jones.
    #14653

    SoZo
    Moderator
    Post count: 1573

    That is actually rather difficult since it’s outside the loop.


    John “Nicolas Flamel” Wright | SoZo’s design| John Wright Photography

    #18546

    emke
    Participant
    Post count: 3

    I’m actually looking for the same thing as Jones. Any pointers on what to do?

    #18625

    Jones
    Participant
    Post count: 5

    I managed to fix it myself, here is the solution @emke:


    if ( is_home() ) {
    echo '<div id="page-title"><div class="wrap"><p>' . esc_html( get_bloginfo( 'description' ) ) . '<a class="page-title-button" href="/contact">' . __( 'Neem direct contact op', 'minimum' ) . '</a></p></div></div>';
    }
    elseif ( is_404() ) {
    echo '<div id="page-title"><div class="wrap"><p>' . __( 'Ooops!', 'minimum' ) . '<a class="page-title-button" href="/contact">' . __( 'Neem direct contact op', 'minimum' ) . '</a></p></div></div>';
    }
    elseif ( is_post_type_archive( 'portfolio' ) || is_singular( 'portfolio') ) {
    echo '<div id="page-title"><div class="wrap"><p>' . __( 'From the Portfolio', 'minimum' ) . '<a class="page-title-button" href="/contact">' . __( 'Neem direct contact op', 'minimum' ) . '</a></p></div></div>';
    }
    elseif ( is_singular( 'page' ) ) {
    echo '<div id="page-title"><div class="wrap"><p>' . esc_html( get_the_title($ID)) . '<a class="page-title-button" href="/contact">' . __( 'Neem direct contact op', 'minimum' ) . '</a></p></div></div>';
    }
    elseif ( is_singular( 'post' ) ) {
    echo '<div id="page-title"><div class="wrap"><p>' . esc_html( get_the_title($ID)) . '<a class="page-title-button" href="/contact">' . __( 'Neem direct contact op', 'minimum' ) . '</a></p></div></div>';
    }
    elseif ( is_author() || is_category() || is_date() || is_search() || is_singular() || is_tag() ) {
    echo '<div id="page-title"><div class="wrap"><p>' . __( 'From the Blog', 'minimum' ) . '<a class="page-title-button" href="/contact">' . __( 'Neem direct contact op', 'minimum' ) . '</a></p></div></div>';
    }
    else {
    echo '<div id="page-title"><div class="wrap"><p>' . esc_html( get_bloginfo( 'description' ) ) . '<a class="page-title-button" href="/contact">' . __( 'Neem direct contact op', 'minimum' ) . '</a></p></div></div>';
    }

    This displays the page title at pages and posts. Its translated so dont mind the ‘neem direct contact op’

     

    let me know if this helped you

    #18774

    emke
    Participant
    Post count: 3

    Yeah, I also managed to get it to work in the mean time. Thanks for your help! :)

    #19121

    emke
    Participant
    Post count: 3

    Hi,

    so I have a problem I cannot figure out how to solve. On my blog page I get the last post title in my page-title area. I would like to have only “Blog” or what ever as the blog page is showing several posts and not only the last one. This is the code I currently have:

    <?php

    if ( is_home() ) {
    echo ‘<div id=”page-title”><div class=”wrap”><h1>’ . esc_html( get_the_title($ID)) . ‘</h1><a class=”page-title-button” href=”/contact”>’ . __( ‘Contact’, ‘minimum’ ) . ‘</a></div></div>’;
    }
    elseif ( is_404() ) {
    echo ‘<div id=”page-title”><div class=”wrap”><h1>’ . __( ‘Ooops!’, ‘minimum’ ) . ‘</h1><a class=”page-title-button” href=”/contact”>’ . __( ‘Contact’, ‘minimum’ ) . ‘</a></div></div>’;
    }
    elseif ( is_singular( ‘page’ ) ) {
    echo ‘<div id=”page-title”><div class=”wrap”><h1>’ . esc_html( get_the_title($ID)) . ‘</h1><a class=”page-title-button” href=”/contact”>’ . __( ‘Contact’, ‘minimum’ ) . ‘</a></div></div>’;
    }
    elseif ( is_singular( ‘post’ ) ) {
    echo ‘<div id=”page-title”><div class=”wrap”><h1>’ . esc_html( get_the_title($ID)) . ‘</h1><a class=”page-title-button” href=”/contact”>’ . __( ‘Contact’, ‘minimum’ ) . ‘</a></div></div>’;
    }
    elseif ( is_author() || is_category() || is_date() || is_search() || is_singular() || is_tag() ) {
    echo ‘<div id=”page-title”><div class=”wrap”><h1>’ . __( ‘From the Blog’, ‘minimum’ ) . ‘</h1><a class=”page-title-button” href=”/contact”>’ . __( ‘Contact’, ‘minimum’ ) . ‘</a></div></div>’;
    }
    else {
    echo ‘<div id=”page-title”><div class=”wrap”><h1>’ . esc_html( get_bloginfo( ‘description’ ) ) . ‘</h1><a class=”page-title-button” href=”/contact”>’ . __( ‘Contact’, ‘minimum’ ) . ‘</a></div></div>’;
    }

    I’ve tried adding:

    }
    elseif ( is_blog() ) {
    echo ‘<div id=”page-title”><div class=”wrap”><h1>’ . __( ‘Ooops!’, ‘minimum’ ) . ‘</h1><a class=”page-title-button” href=”/contact”>’ . __( ‘Contact’, ‘minimum’ ) . ‘</a></div></div>’;
    }

    but then nothing works. Can anyone help me out please?

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.