Support » Fixing WordPress » checking if page is the wordpress default blog landing page

  • Resolved justinblayney

    (@justinblayney)


    Hello,
    I am trying to test if a page is the default wordpress Blog landing page..

    i created a page named blog and this is different than the home page. The $post->ID for blog is 13

    usually i could test for $post->ID, but because it has blog articles, the post ID becomes the ID the the first article in the list instead of 13…

    Also, i only want to check for this page, if it is a category, article, author,etc.. listing I do not want these pages.. i only want the initial page for the blog

Viewing 15 replies - 1 through 15 (of 34 total)
  • Josh

    (@josh401)

    Moderator and Editor Customizer

    Hi Josh, thanks for the help… i think i am missing something though…

    if (is_page(‘creative-blog’)) { echo “blog”;} else { echo”not blog”; }

    this always echos “not blog”, what is wrong with my if statement

    (the slug is actually named creative-blog

    Josh

    (@josh401)

    Moderator and Editor Customizer

    What is it exactly you are wanting to do?

    Are you making a page template and running this code from the template?

    So i tried some other code

    $post = get_post($post->ID);
    $slug = $post->post_name;
    echo $slug;
    if ( $slug == “creative-blog”) { echo “blog”;} else { echo”not blog”; }

    the problem is slug variable always changes to the top article in the list , even thought the URL reads /creative-blog

    What i am doing is this…

    the Blog landing page will have a very specific style including header and menu….. the other pages (categories, tags, single, etc…) will have a different style..

    So i need to isolate the very first page people land on when they click my blog link, the page i designated in dashboard – settings – reading – Posts page:

    i am running this code is the header.php and functions page

    Josh

    (@josh401)

    Moderator and Editor Customizer

    What is the url to that landing page?

    /creative-blog

    Josh

    (@josh401)

    Moderator and Editor Customizer

    I mean, do you have it live?

    http://www.jarcreative.com/wordpress/creative-blog/

    i am dumping my variable in the top left corner..

    you will notice the SLUG echo is correct for every page except Blog, on blog it turns into the first article

    Josh

    (@josh401)

    Moderator and Editor Customizer

    Let’s try this:

    if(is_front_page()) {

    this works fine.. but it isnt the front page so no good to me

    Josh

    (@josh401)

    Moderator and Editor Customizer

    How do you have your settings configured of what page to display be default?

    settings -> general -> reading

    Josh

    (@josh401)

    Moderator and Editor Customizer

    Why don’t you just make a page template… and assign that as your blog main page?

    This will give the page an ID… which can then be used for conditional formatting.

    i have blog choosen

    ok, i copied and pasted index.php, named it blog-landing page.. and gave it template tag

    i wnet into pages – blog and told choosen that as my template..

    makes no difference..

    this is a huge hole in wordpress, the blog landing page does not seem to exist as a actual page

Viewing 15 replies - 1 through 15 (of 34 total)
  • The topic ‘checking if page is the wordpress default blog landing page’ is closed to new replies.