[resolved] Trying to show the contents of a specific post (2 posts)

  1. peiqinglong
    Posted 7 years ago #

    Ok, so I'm trying to learn more about plugins and the functions.php file. What I'm trying to accomplish is to query the WP database and find the post_name of About and display it. This is what I have in my functions.php file:

    function about_page_excerpt() {
    	global $wpdb, $tableposts;
    	$aboutme = $wpdb->get_col("SELECT post_content FROM $wpdb->posts WHERE post_name = 'about'");
    	echo $aboutme;

    Now when I try to use <?php about_page_excerpt(); ?> I get Array as the display. What am I doing wrong? Thanks!

  2. peiqinglong
    Posted 7 years ago #

    Haha, stupid me, I should be using $wpdb->get_var and not get_col.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.