Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme »

Custom php in a page


  #1  
Old Apr 4, 2010, 02:59 PM
ccw
 
8 posts · Apr 2009
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
  #2  
Old Apr 5, 2010, 05:54 AM
juggledad's Avatar
juggledad
 
23,667 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Last edited by juggledad; Apr 5, 2010 at 05:56 AM.
  #3  
Old Apr 5, 2010, 08:55 AM
ccw
 
8 posts · Apr 2009
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.
Attached Thumbnails
Click image for larger version

Name:	attributes.jpg
Views:	522
Size:	24.7 KB
ID:	457  
  #4  
Old Apr 5, 2010, 09:09 AM
juggledad's Avatar
juggledad
 
23,667 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
did you put your xxxxx.php in the atahualpa theme folder?
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Apr 5, 2010, 09:42 AM
Wimbledon's Avatar
Wimbledon
 
320 posts · Apr 2009
[VA & AZ], USA
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.

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
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
[SOLVED] Hide left sidebar on just one custom php page that isn't in the options list marced Sidebars & Widgets 13 Mar 2, 2010 01:35 PM
[SOLVED] Custom header.php &amp; css: logo doesn't show dougc Header configuration & styling 4 Feb 1, 2010 11:00 AM
Add custom php/js menu below header dmtompki Header configuration & styling 6 Jun 23, 2009 10:03 AM
make index.php be a "page" and blog postings go to different php page zhidoni Atahualpa 3 Wordpress theme 0 Jun 21, 2009 04:25 PM


All times are GMT -6. The time now is 11:36 PM.


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