Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter sophieyanow

    (@sophieyanow)

    Thank you for the thorough explanation. Before I saw your response I ended up going the replacement route, with slightly different implementation:

    add_filter( 'nav_menu_link_attributes', 'menu_override', 10, 3 );
    function menu_override( $atts, $item, $args ) {
    	global $post;
        $placeholder = $post;
        $args = array(
            'numberposts'     => 1,
            'offset'          => 0,
            'orderby'         => 'post_date',
            'order'           => 'DESC',
            'post_status'     => 'publish',
            'fields' => 'ids',
            'post_type' => array( 'post' ), // if you want the latest post(blog), page( if you want the latest page published), or 'post', 'page' if you want the latest post or page publish. or any other custom post type you may want/need
         );
        $sorted_posts = get_posts( $args );
        $latestpostid = $sorted_posts[0];
        $newlink = str_replace("--id--", $latestpostid, $atts[href]);
        $atts[href] = $newlink;
        return $atts;
    }

    Definitely learning a lot here!

    Thread Starter sophieyanow

    (@sophieyanow)

    It’s not a commercial theme, it’s a GNU licensed theme that has never been supported.

    I figured my question was more general, about using developer tools to pinpoint/locate something. Just looking for any dev to give me general advice. If that’s not allowed here then apologies.

    Thread Starter sophieyanow

    (@sophieyanow)

    Thanks MichaelH! Awesome. I have very little knowledge of PHP and I’ve forgotten a lot of other programming… but that makes sense. I’ll try it out.

    Thread Starter sophieyanow

    (@sophieyanow)

    Yeah, I refreshed the page (using CMD + R, I’m on a Mac) and emptied my browser cache. Still no luck. It’s quite bizarre; does WordPress have some kind of internal cache that needs to be refreshed?

Viewing 4 replies - 1 through 4 (of 4 total)