Forum Replies Created

Viewing 8 replies - 151 through 158 (of 158 total)
  • Thread Starter candell

    (@candell)

    Sorry to be talking to myself, but I feel I am getting closer, my query returns an empty result though. Here is my latest effort

    SELECT wp_posts.id, wp_posts.post_title, wp_postmeta.meta_value, wp_postmeta.meta_value FROM wp_posts, wp_postmeta
    WHERE wp_posts.ID = wp_postmeta.post_id
    AND wp_postmeta.meta_value = '_wp_attached_file'
    AND wp_posts.post_status = 'publish'
    AND wp_posts.post_date < NOW()
    AND wp_postmeta.meta_value = 'scheme.php'
    ORDER BY wp_posts.post_date DESC
    Thread Starter candell

    (@candell)

    Update

    Just noticed that the featured image is actually in the postmeta table so I modified my code to

    <?php
    
     $querystr = "
        SELECT $wpdb->posts.id, $wpdb->posts.post_title, $wpdb->postmeta.meta_value, $wpdb->postmeta._wp_attached_file
        FROM $wpdb->posts, $wpdb->postmeta
        WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
        AND $wpdb->posts.post_status = 'publish'
        AND $wpdb->posts.post_date < NOW()
    	AND $wpdb->postmeta.meta_value = 'scheme.php'
        ORDER BY $wpdb->posts.post_date DESC
     ";
    
     $theposts = $wpdb->get_results($querystr);
    
     foreach ($theposts as $pageresult) {
    
        echo '<p><img src=' .$pageresult->_wp_attached_file. ' class=alignleft />' .$pageresult->post_title. '</p>';
    
    }
    
     ?>

    But this returns nothing. Looking more into the database, one post can have multiple entries in postmeta, in my case I need to pull out two rows from post meta (along with some data from posts) but it is stopping after it finds the first.

    How can I modify my code to get the feaqtured image out?

    Thanks

    Thread Starter candell

    (@candell)

    I am getting closer, ignore the SQL at the moment as I need to figure out how to grab the name of the level above the properties to get the area.

    global $wpdb;
    
    $searchresults = $wpdb->get_results( "SELECT * FROM wp_posts where post_parent ='0'" );
    
    if ($searchresults)
    {
    global $post;
    foreach ($searchresults as $post)
    { 
    
    echo "<li><a href=''>".the_title()."</a></li>";
            }
          }

    but the output isn`t as I would expect, i.e. the page name is being printed outside of the list.

    e.g.

    Welcome

    • Sample Page

    • Homepage

    Thread Starter candell

    (@candell)

    Got it thanks

    Thread Starter candell

    (@candell)

    am I allowed to bump my own post on wordpress forums?

    Thread Starter candell

    (@candell)

    Works great thank you

    Thread Starter candell

    (@candell)

    Hi

    Thanks for your help, just struggling to use this though. How do I add the link_before to <?php wp_list_pages(); ?> so that the ‘<li class=”pagenav”>Pages‘ bit doesn`t show?

    edit: just figured out this bit, thanks. Can you still help with the next part of my post…?

    Also, I added to Settings > Permalinks > Category base the word blog, I guess I need to edit the Custom structure field to make this happen? If I do, what needs to go in here?

    Thanks

    Thread Starter candell

    (@candell)

    bump :o)

Viewing 8 replies - 151 through 158 (of 158 total)