• What I’m trying is having a list of latest post on the frontpage gotten from the blog on a seperate page.

    Now… How would I add a anchor to the post in the blog and get it on the frontpage loop, in such a way that when the user click the frontpage post exerpt it will not go to the permalink single post, but down to the individual post in the list of posts in the main blog.

    make any sense?

    thanks folks

Viewing 6 replies - 1 through 6 (of 6 total)
  • in the blog page, the anchor could be a div with a css id:
    example from the default theme:

    <div class="post" id="post-<?php the_ID(); ?>">

    (you may need to adapt the existing div that holds the post)

    in the frontpage, the linked title of the post needs to point to the blog page plus the anchor id:
    for instance for the above example:

    <?php global $wpdb; $pageid = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = 'all-posts-excerpt'"); ?>
    		<h2><a href="<?php echo get_permalink($pageid).'#post-'.get_the_ID(); ?>" ><?php the_title(); ?></a></h2>

    where ‘all-posts-excerpt’ is the page slug of the blog page.

    Thread Starter pisosse

    (@pisosse)

    THANKS!

    just have to wrap my head around it.. ??

    Thread Starter pisosse

    (@pisosse)

    Shouldn’t I be able to use permalink_anchor?

    reference

    And would it be a problem on a sandbox theme?

    Thread Starter pisosse

    (@pisosse)

    Well.. permalink_anchor dosn’t get me any where.. let me just make a picture of where I am..

    I got an external loop outside the the wordpress dir. I get title and excerpts from the main loop( since I want to make a costum excerpt text and not only the more tag) I get a permalink on the title as is, but I want it to do what permalink_anchor says it does, namly link to the post anchor in the main blog from the wordpress dir.

    alchymyth properly got it right but I’m just not quite sure that i understand it?

    Like should I somehow edit ‘all-posts-excerpt’ with some parameter?(eg. the slugpage)

    Thread Starter pisosse

    (@pisosse)

    well my mainblog page don’t have a slug… jeez I’m spun arouuund here.. sorry guys

    Thread Starter pisosse

    (@pisosse)

    YAAAAY got it with get_bloginfo!

    quite easy
    <h2><a href="<?php echo get_bloginfo ( 'url' ).'#post-'.get_the_ID(); ?>" ><?php the_title(); ?></a></h2>

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘auto add anchor and get them from loop?’ is closed to new replies.