Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages »

[SOLVED] post_id


  #1  
Old Jan 21, 2010, 08:36 AM
ntrast
 
11 posts · Jan 2010
Hello,

after banging my head for 3 days now i decided to post here and ask for help.

Due to a couple of syndications (RSS Feeds) i need to format some of the syndicated posts with different css settings (e.g. images to float left, paragraphs to get smaller margins, etc.). To do this i add custom fields while i grap the rss feeds. This customfields than get applied to the post as css class. This all is working perfect but now i need the post id for my div container aswell. And that is where i strugle.

I use Atahualpa 3.4.5.1 and i tried the following code in "The Loop" from the "style and edit center column" section:

PHP Code:
<?php 
/* get custom field myclass for this post */
$myclass get_post_custom_values("myclass");

/* check wether myclass has any value */
if ($myclass == ''){

/* no value? use standard output */
bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>');

} else {

/* we got value! now add an additional div container */
bfa_post_bodycopy('<div class="post-bodycopy clearfix"><div class ="'.$myclass[0].'" id="myid'.the_ID().'">','</div></div>');
}
?>
The problem is in the else part of the condition. the_ID() gets always printed in the post instead of beeing "hidden" in the div container. The second div should be e.g. <div class="classfrommyclass" id="myid999">. It works well if i dont use the id tag (<div class ="'.$myclass[0].'">).

If tried <div class ="'.$myclass[0].'" id="myid'.$post->ID.'"> aswell. But that does not output the post_id.

I can wrap an additional div arround the bfa_post_bodycopy with the id in it:

PHP Code:
<?php 
$myclass 
get_post_custom_values("myclass");
if (
$myclass == ''){
bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>');
} else {
?><div id=pb"<?php the_ID(); ?>"><?php
bfa_post_bodycopy
('<div class="post-bodycopy clearfix"><div class ="'.$myclass[0].'">','</div></div>'); 
?></div><?php
}
?>
but i need the post-id within the bfa_post_bodycopy in my second div. How can this be done? Why is the_ID() only working outside and not inside bfa_post_bodycopy? And why cant i use $post->ID?

Can anyone please push me into the right direction? What am i missing?

Regards

Michael
  #2  
Old Jan 21, 2010, 08:44 AM
ntrast
 
11 posts · Jan 2010
while writing the question i found the answer

PHP Code:
<?php 
$myclass 
get_post_custom_values("myclass");
$mypostid "myid" get_the_ID();
if (
$myclass == ''){
bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>');
} else {
bfa_post_bodycopy('<div class="post-bodycopy clearfix"><div class="'.$myclass[0].'" id="'.$mypostid.'">','</div></div>'); 
}
?>
Sometimes it is so easy ...

Regards

Michael

Bookmarks




All times are GMT -6. The time now is 12:02 AM.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.