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 »

How to add php code to a 'single' page


  #1  
Old Feb 9, 2010, 07:53 AM
JakeThePeg
 
37 posts · Aug 2009
Howdy,

I am hacking a plugin to fit in with my Atahualpa theme. It requires me to add some PHP code to the 'single posts' page...most other themes have a simple 'single.php' file, however I'm not sure this is the case with Atahualpa is it?

Where abouts would I slot in this PHP code so that it only appears on the single post pages?
  #2  
Old Feb 15, 2010, 06:23 AM
Rashell's Avatar
Rashell
 
67 posts · May 2009
in the "center column---> inside the loop" with a conditional statement like

Code:
<?php if is_single() AND "then add the rest of your php code">
Rashell
  #3  
Old Mar 14, 2010, 01:27 AM
JakeThePeg
 
37 posts · Aug 2009
Sorry to ask a really basic question....but I don't know how the IF statements work in PHP.

This is the PHP code I want to insert....

PHP Code:
$post_cats get_the_categories(); 
$post_coordinates GeoMashup::post_coordinates(); 
if ( 
$post_coordinates ) { 
  echo 
GeoMashup::map'map_content=global&map_cat='$post_cats[0]->cat_ID 
'&center_lat' $post_coordinates['lat'] . '&center_lng=' 
$post_coordinates['lng'] ); 

How do I incorporate that into the IF statement you mentioned above?
  #4  
Old Mar 15, 2010, 05:27 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
try this
HTML Code:
<?php if is_single() {
$post_cats = get_the_categories();  
$post_coordinates = GeoMashup::post_coordinates();  
if ( $post_coordinates ) {  
  echo GeoMashup::map( 'map_content=global&map_cat='. $post_cats[0]->cat_ID  
. '&center_lat' . $post_coordinates['lat'] . '&center_lng=' .  
$post_coordinates['lng'] );  
} } ?>
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Mar 17, 2010, 08:09 AM
JakeThePeg
 
37 posts · Aug 2009
Quote:
Originally Posted by juggledad
try this
HTML Code:
<?php if is_single() {
$post_cats = get_the_categories();  
$post_coordinates = GeoMashup::post_coordinates();  
if ( $post_coordinates ) {  
  echo GeoMashup::map( 'map_content=global&map_cat='. $post_cats[0]->cat_ID  
. '&center_lat' . $post_coordinates['lat'] . '&center_lng=' .  
$post_coordinates['lng'] );  
} } ?>
Thanks, I tried pasting the above code at the end of the "The Loop" section in the Centre Column tab of the Athualpa theme options, and the following error came up on the front end.

Parse error: syntax error, unexpected T_STRING, expecting '(' in /home/jake13/public_html/shackn/wp-content/themes/atahualpa/functions.php(389) : eval()'d code on line 22

Any ideas why?
  #6  
Old Mar 17, 2010, 02:17 PM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
try putting a () around the 'is_single()' so it would be 'if (is_single() )'
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #7  
Old Mar 18, 2010, 02:04 AM
JakeThePeg
 
37 posts · Aug 2009
Thanks, I tried what you said, and now I get another error

Fatal error: Call to undefined function get_the_categories() in /home/jake13/public_html/shackn/wp-content/themes/atahualpa/functions.php(389) : eval()'d code on line 23
  #8  
Old Mar 18, 2010, 04:27 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
well that is from your original code you wanted to insert. That error says that the function 'get_the_categories()' doesn't exist.

Where did you get this code from? if it is a plugin, it should have had that function in it. If you were doing this properly, the code snippet should test to see if the function exists then display a notice on the page to that effect.

But you need to go back and look at the original plugin, you are missing something
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #9  
Old Mar 21, 2010, 01:21 AM
JakeThePeg
 
37 posts · Aug 2009
Ok, cool, thanks for the advice, I'll speak to the plugin creator and report back with my findings

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
php in single post Haser Atahualpa 3 Wordpress theme 3 Dec 4, 2012 07:54 PM
Pls help me change this code<title><?php bloginfo('name'); ?><?php wp_title(); ?></ti tobywinn Header configuration & styling 1 Nov 18, 2011 11:51 AM
Why no single.php DavePorter Plugins & Atahualpa 5 Apr 23, 2010 06:45 PM
Where to put code to add background image to Page menu? 3busydogs Page & Category Menu Bars 1 Dec 29, 2009 01:45 PM
[SOLVED] HELP! I tried to add something to my function.php page mgofootball Header configuration & styling 1 Jun 25, 2009 12:35 PM


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


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