Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

thestripedone on "Echoing a link to the oldest post in a navigation menu"

$
0
0

I'm putting together a webcomic page for a friend and am having trouble figuring out how to link to the first post. (That is: the oldest post, not the most recent)

Currently I have the following in functions.php, which as far as I can tell should be giving me a link to the oldest post:

function get_first_post() {

	//Get all posts
	$query = 'posts_per_page=-1';

	$queryObject = new WP_Query($query);

	//the loop
	$first_post_link=get_permalink();

	//clear post data
	wp_reset_postdata();

	//return result
	return $fist_post_link;
}//get_first_post

However, when I try to call it with a variable, the variable ends up empty.

I saw in a few places that I should be calling functions like get_permalink as a method of the object (e.g. $queryObject->get_permalink()) but whenever I try that my webhost serves me a 500 error for this function. I can call do that in other PHP functions no problem, though.

What am I doing wrong?

If it matters, this functions.php is part of a child theme of the Parabola theme.


Viewing all articles
Browse latest Browse all 8245

Trending Articles