Support » Themes and Templates » Help please! – Loop work fine on local server but doesn't so on website

  • Resolved rereradu


    I have edited the loop to display a link to the file attached inside a post in the “post meta data” area. While I am running the loop on my localserver installation, everything works just fine, I get everything displayed correctly, something like this

    Post 1
    link | comments etc…

    Post 2
    link | comments etc…

    But on the website it doesn’t work! (While displaying posts on the search result page, the link reffers to the search link)
    For example, searching for post Title1, I get this

    Search results

    link | comments etc…
    but the link doesn’t refer to the attachment inside the post, but to the current url (websiteurl/?s=Title1&submit=Go)

    I am using the same theme, with the same files. So I don’t understand why it isn’t working on the website, but it does so on the localhost.

    Here is the code I used inside the loop to get the attachment url:

    $docs =& get_children( array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'application/pdf', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
    if ( empty($docs) ) {
    	$attachment_url = "#";
    } else {
    	foreach ( $docs as $attachment_id => $attachment ) {
    		$attachment_url =& wp_get_attachment_url( $attachment_id );

    And then somewhere below, this, to display the link where I want it:
    <a href="<?php echo $attachment_url ?>"> Download </a> | <a href="localhost/"

    Again, I am using exactly the same theme with the same files.
    What is wrong?
    Please help me.
    Best regards,

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Help please! – Loop work fine on local server but doesn't so on website’ is closed to new replies.