Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Atahualpa 3 Wordpress theme (http://forum.bytesforall.com/forumdisplay.php?f=2)
-   -   Custom php in a page (http://forum.bytesforall.com/showthread.php?t=6595)

ccw Apr 4, 2010 02:59 PM

Custom php in a page
 
The site that I am working on is:

http://www.thewrightrecipes.com

I'm trying to build a "Recipe Index" page. I started by installing the AZIndex plugin and thought that this would work great. I could create a custom field with the recipe title (seldom the same as the post title) and sort by Category/custom field. Unfortunately, there is often more than 1 recipe per post. While I could add numerous custom fields to each post with the same key, AZIndex will only return 1 value per post.
Id like to build an index page making use of php code to return custom field values. I think that I could hack my way through it if I even knew where to begin. How do you create pages using custom php code like this:

<ul>
<?php
$sweets = get_posts('category=7&numberposts=-1&orderby=post_name&order=ASC');
foreach($sweets as $post) : setup_postdata($post);
?>
<li>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
<?php $sweets = get_post_meta($post->ID, "sweets", $single = true);
if($sweets !== '') {
echo 'by ' . $sweets;
} ?>
</li>
<?php endforeach; ?>
</ul>

Where does that go? Is this too basic of a question? Any help would be appreciated.

Thanks

juggledad Apr 5, 2010 05:54 AM

you can create your own page using index.php as a start. Copy it and you can remove anything from
<?php /* If there are any posts: */
thru
<?php bfa_center_content($bfa_ata['center_content_bottom']); ?>
and put your own code there.

if you want to make it a page template, you will have to add
HTML Code:

<?php
/*
Template Name: mytemplate template
*/
 ?>

<?php // Do not delete these lines ?>
------

at the very begining of the file

ccw Apr 5, 2010 08:55 AM

1 Attachment(s)
Thanks for the reply. That gives me a good starting point.

However, now that I've created a page template, how do I apply it to a page? In my "Attributes" section, I don't have a "Template" area.

(See attached screenshot)

Is this a version issue?

Thanks in advance.

juggledad Apr 5, 2010 09:09 AM

did you put your xxxxx.php in the atahualpa theme folder?

Wimbledon Apr 5, 2010 09:42 AM

Another way you can do this is to activate the Exec-PHP plugin, and then paste the code into a new page. Simple. :)

I'm doing this on another site with custom fields.


All times are GMT -6. The time now is 05:10 PM.

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