Skip to main content
Clarified what happens when <?php the_content(); ?> is used in loop
Source Link

My page (outside the wordpress install) begins something like this:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';

$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'post'
);
$queryObject = new WP_Query($args);

I start the loop like so:

<?php while (have_posts()): the_post(); ?>

In the loop I call this:

<?php the_post_thumbnail();?>

But nothing is returned.

print_r(get_post(4));

(Where 4 is the id of an attachment) also returns nothing.

Calling

<?php the_content(); ?>

echoes the post content, minus the gallery - which also doesn't get rendered, but the shortcode is removed.

Inside wordpress everything works fine, outside it seems that attachments are simply ignored. Why does this happen? Is there a workaround? Is there something wrong with my query?

.

.

.

I found an alternative solution to my original problem - using a subdirectory, but I still feel this is a valid question. The original is here:

I'm using the wordpress engine as a CMS for a website that can't be integrated into wordpress right now because of time constraints (but will be eventually), so I need to get hold of things like post thumbnails outside of the wordpress directory. I'm using the following to set up my loop:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';
$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'leather_swatch'
);
$loop = new WP_Query($args);

if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();

However, in index.php this works, but returns nothing in my external loop:

$thumb = get_post_thumbnail_id($post->ID);
echo '<img src="'.wp_get_attachment_url($thumb).'" />';

What I find really odd is that

print_r(get_post($thumb)); 

returns a post object inside the wordpress directory, but nothing in my custom loop - it doesn't recognise attachments. However I can still print out the content of my post type in the custom loop using the standard the_content() function.

Can anyone illuminate what's going on/how I might fix this? I don't really want to use custom meta data to replicate standard functionality.

My page (outside the wordpress install) begins something like this:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';

$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'post'
);
$queryObject = new WP_Query($args);

I start the loop like so:

<?php while (have_posts()): the_post(); ?>

In the loop I call this:

<?php the_post_thumbnail();?>

But nothing is returned.

print_r(get_post(4));

(Where 4 is the id of an attachment) also returns nothing.

Calling

<?php the_content(); ?>

echoes the post content.

Inside wordpress everything works fine, outside it seems that attachments are simply ignored. Why does this happen? Is there a workaround? Is there something wrong with my query?

.

.

.

I found an alternative solution to my original problem - using a subdirectory, but I still feel this is a valid question. The original is here:

I'm using the wordpress engine as a CMS for a website that can't be integrated into wordpress right now because of time constraints (but will be eventually), so I need to get hold of things like post thumbnails outside of the wordpress directory. I'm using the following to set up my loop:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';
$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'leather_swatch'
);
$loop = new WP_Query($args);

if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();

However, in index.php this works, but returns nothing in my external loop:

$thumb = get_post_thumbnail_id($post->ID);
echo '<img src="'.wp_get_attachment_url($thumb).'" />';

What I find really odd is that

print_r(get_post($thumb)); 

returns a post object inside the wordpress directory, but nothing in my custom loop - it doesn't recognise attachments. However I can still print out the content of my post type in the custom loop using the standard the_content() function.

Can anyone illuminate what's going on/how I might fix this? I don't really want to use custom meta data to replicate standard functionality.

My page (outside the wordpress install) begins something like this:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';

$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'post'
);
$queryObject = new WP_Query($args);

I start the loop like so:

<?php while (have_posts()): the_post(); ?>

In the loop I call this:

<?php the_post_thumbnail();?>

But nothing is returned.

print_r(get_post(4));

(Where 4 is the id of an attachment) also returns nothing.

Calling

<?php the_content(); ?>

echoes the post content, minus the gallery - which also doesn't get rendered, but the shortcode is removed.

Inside wordpress everything works fine, outside it seems that attachments are simply ignored. Why does this happen? Is there a workaround? Is there something wrong with my query?

.

.

.

I found an alternative solution to my original problem - using a subdirectory, but I still feel this is a valid question. The original is here:

I'm using the wordpress engine as a CMS for a website that can't be integrated into wordpress right now because of time constraints (but will be eventually), so I need to get hold of things like post thumbnails outside of the wordpress directory. I'm using the following to set up my loop:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';
$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'leather_swatch'
);
$loop = new WP_Query($args);

if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();

However, in index.php this works, but returns nothing in my external loop:

$thumb = get_post_thumbnail_id($post->ID);
echo '<img src="'.wp_get_attachment_url($thumb).'" />';

What I find really odd is that

print_r(get_post($thumb)); 

returns a post object inside the wordpress directory, but nothing in my custom loop - it doesn't recognise attachments. However I can still print out the content of my post type in the custom loop using the standard the_content() function.

Can anyone illuminate what's going on/how I might fix this? I don't really want to use custom meta data to replicate standard functionality.

Broadened issue after some testing
Source Link

Custom Post Impossible to get Attachments outsideOutside Wordpress?

My page (outside the wordpress install) begins something like this:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';

$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'post'
);
$queryObject = new WP_Query($args);

I start the loop like so:

<?php while (have_posts()): the_post(); ?>

In the loop I call this:

<?php the_post_thumbnail();?>

But nothing is returned.

print_r(get_post(4));

(Where 4 is the id of an attachment) also returns nothing.

Calling

<?php the_content(); ?>

echoes the post content.

Inside wordpress everything works fine, outside it seems that attachments are simply ignored. Why does this happen? Is there a workaround? Is there something wrong with my query?

.

.

.

I found an alternative solution to my original problem - using a subdirectory, but I still feel this is a valid question. The original is here:

I'm using the wordpress engine as a CMS for a website that can't be integrated into wordpress right now because of time constraints (but will be eventually), so I need to get hold of things like post thumbnails outside of the wordpress directory. I'm using the following to set up my loop:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';
$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'leather_swatch'
);
$loop = new WP_Query($args);

if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();

However, in index.php this works, but returns nothing in my external loop:

$thumb = get_post_thumbnail_id($post->ID);
echo '<img src="'.wp_get_attachment_url($thumb).'" />';

What I find really odd is that

print_r(get_post($thumb)); 

returns a post object inside the wordpress directory, but nothing in my custom loop - it doesn't recognise attachments. However I can still print out the content of my post type in the custom loop using the standard the_content() function.

Can anyone illuminate what's going on/how I might fix this? I don't really want to use custom meta data to replicate standard functionality.

Custom Post Attachments outside Wordpress

I'm using the wordpress engine as a CMS for a website that can't be integrated into wordpress right now because of time constraints (but will be eventually), so I need to get hold of things like post thumbnails outside of the wordpress directory. I'm using the following to set up my loop:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';
$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'leather_swatch'
);
$loop = new WP_Query($args);

if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();

However, in index.php this works, but returns nothing in my external loop:

$thumb = get_post_thumbnail_id($post->ID);
echo '<img src="'.wp_get_attachment_url($thumb).'" />';

What I find really odd is that

print_r(get_post($thumb)); 

returns a post object inside the wordpress directory, but nothing in my custom loop - it doesn't recognise attachments. However I can still print out the content of my post type in the custom loop using the standard the_content() function.

Can anyone illuminate what's going on/how I might fix this? I don't really want to use custom meta data to replicate standard functionality.

Impossible to get Attachments Outside Wordpress?

My page (outside the wordpress install) begins something like this:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';

$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'post'
);
$queryObject = new WP_Query($args);

I start the loop like so:

<?php while (have_posts()): the_post(); ?>

In the loop I call this:

<?php the_post_thumbnail();?>

But nothing is returned.

print_r(get_post(4));

(Where 4 is the id of an attachment) also returns nothing.

Calling

<?php the_content(); ?>

echoes the post content.

Inside wordpress everything works fine, outside it seems that attachments are simply ignored. Why does this happen? Is there a workaround? Is there something wrong with my query?

.

.

.

I found an alternative solution to my original problem - using a subdirectory, but I still feel this is a valid question. The original is here:

I'm using the wordpress engine as a CMS for a website that can't be integrated into wordpress right now because of time constraints (but will be eventually), so I need to get hold of things like post thumbnails outside of the wordpress directory. I'm using the following to set up my loop:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';
$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'leather_swatch'
);
$loop = new WP_Query($args);

if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();

However, in index.php this works, but returns nothing in my external loop:

$thumb = get_post_thumbnail_id($post->ID);
echo '<img src="'.wp_get_attachment_url($thumb).'" />';

What I find really odd is that

print_r(get_post($thumb)); 

returns a post object inside the wordpress directory, but nothing in my custom loop - it doesn't recognise attachments. However I can still print out the content of my post type in the custom loop using the standard the_content() function.

Can anyone illuminate what's going on/how I might fix this? I don't really want to use custom meta data to replicate standard functionality.

Tweeted twitter.com/#!/StackWordPress/status/413030223727570944
Explained why integration isn't possible right now
Source Link

I'm using the wordpress engine as a CMS for a website that can't be integrated into wordpress at thisright now because of time constraints (but will be eventually), so I need to get hold of things like post thumbnails outside of the wordpress directory. I'm using the following to set up my loop:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';
$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'leather_swatch'
);
$loop = new WP_Query($args);

if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();

However, in index.php this works, but returns nothing in my external loop:

$thumb = get_post_thumbnail_id($post->ID);
echo '<img src="'.wp_get_attachment_url($thumb).'" />';

What I find really odd is that

print_r(get_post($thumb)); 

returns a post object inside the wordpress directory, but nothing in my custom loop - it doesn't recognise attachments. However I can still print out the content of my post type in the custom loop using the standard the_content() function.

Can anyone illuminate what's going on/how I might fix this? I don't really want to use custom meta data to replicate standard functionality.

I'm using the wordpress engine as a CMS for a website that can't be integrated into wordpress at this time, so I need to get hold of things like post thumbnails outside of the wordpress directory. I'm using the following to set up my loop:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';
$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'leather_swatch'
);
$loop = new WP_Query($args);

if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();

However, in index.php this works, but returns nothing in my external loop:

$thumb = get_post_thumbnail_id($post->ID);
echo '<img src="'.wp_get_attachment_url($thumb).'" />';

What I find really odd is that

print_r(get_post($thumb)); 

returns a post object inside the wordpress directory, but nothing in my custom loop - it doesn't recognise attachments. However I can still print out the content of my post type in the custom loop using the standard the_content() function.

Can anyone illuminate what's going on/how I might fix this? I don't really want to use custom meta data to replicate standard functionality.

I'm using the wordpress engine as a CMS for a website that can't be integrated into wordpress right now because of time constraints (but will be eventually), so I need to get hold of things like post thumbnails outside of the wordpress directory. I'm using the following to set up my loop:

global $wpdb, $wp_query; 
define('WP_USE_THEMES', false);
include_once 'word/wp-blog-header.php';
$args = array(
  'posts_per_page'  => 10,
  'post_type'       => 'leather_swatch'
);
$loop = new WP_Query($args);

if ($loop->have_posts()) : while ($loop->have_posts()) : $loop->the_post();

However, in index.php this works, but returns nothing in my external loop:

$thumb = get_post_thumbnail_id($post->ID);
echo '<img src="'.wp_get_attachment_url($thumb).'" />';

What I find really odd is that

print_r(get_post($thumb)); 

returns a post object inside the wordpress directory, but nothing in my custom loop - it doesn't recognise attachments. However I can still print out the content of my post type in the custom loop using the standard the_content() function.

Can anyone illuminate what's going on/how I might fix this? I don't really want to use custom meta data to replicate standard functionality.

Accurate and more succinct
Link
Loading
Spelling mistake
Source Link
Loading
Even more accuracy
Link
Loading
Attempted to more accurately describe the question
Link
Loading
Source Link
Loading