WordPress.org

Ready to get started?Download WordPress

Forums

Custom Code in Custom Page (15 posts)

  1. yeagerc50
    Member
    Posted 2 years ago #

    I have a simple script that displays each row of data in a block of html. Works fine in my editor but when I call it in my custom page it "skips" the first row of data (displays the back ground image but no data) and at the end (of course) it skips the back ground image and displays the data.
    '<?php

    /**
    * Template Name: Custom Template
    * Description: A Page for Custom Coding
    */
    get_header();
    include("display_cars1.php");
    get_sidebar();
    get_footer();
    ?>'

    Would appreciate any help.

  2. s_ha_dum
    Member
    Posted 2 years ago #

    The interesting code is in display_cars1.php. Why didn't you post that( to the pastebin)?

    Also, you should be using get_template_part.

  3. yeagerc50
    Member
    Posted 2 years ago #

    http://pastebin.com/embed.php?i=SrQQwfLV

    First time with this so don't laugh too loud :)

  4. yeagerc50
    Member
    Posted 2 years ago #

    I forgot to mention I'm running this in the core template folder of twentyten. I haven't created a child theme.

  5. s_ha_dum
    Member
    Posted 2 years ago #

    The url you wanted was this one:

    http://pastebin.com/SrQQwfLV

    :) :)

    That is an odd animal you have there.

    You are echoing a doctype, html, head, and body tags-- multiple times-- inside the ones that WordPress echoes. Those should be one per page.

    You've got multiple duplicate id elements.

    Font tags are deprecated.

    I assume the img on line 25 is what you are calling a 'background' image. I don't see any reason that shouldn't work (in broad strokes) but I don't know what $row looks like either.

  6. yeagerc50
    Member
    Posted 2 years ago #

    http://s245.photobucket.com/albums/gg52/JHCORSAIR/Screenshots/

    Just wanted to show you what it looks like when it displays properly.

    The worst part .....not sure what I did to fix it.

    Typical php newbie :)

  7. s_ha_dum
    Member
    Posted 2 years ago #

    Do you have a URL that I can get to?

  8. yeagerc50
    Member
    Posted 2 years ago #

    I'll get it up on my site and get back to you.

    joomlawebsitesbyjim.com/

    Click the My WordPress Blog tab.

  9. s_ha_dum
    Member
    Posted 2 years ago #

    You have an error even before the loop starts.

  10. yeagerc50
    Member
    Posted 2 years ago #

    http://www.joomlawebsitesbyjim.com/wordpress/custom-page/

    Ok.. it's running. Just messing with the css bugs for now and I'll get the images later. I made a few corrections.

    I think I jumped the gun. It's not grabbing all the rows ......it's a wip.

  11. s_ha_dum
    Member
    Posted 2 years ago #

    You should revisit my earlier post. You have a pile of errors on that page, as I knew you would.

  12. Eric Hoanshelt
    Member
    Posted 2 years ago #

    Hey yeagerc50,

    I think your over thinking this. Your using WordPress so alot of this code is unnecessary if you use the right WordPress functions.

    For example, check out this page to run custom queries:
    http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results

    Here is a very basic example of how this custom code template should look like (it's 1 in the morning here so use this as reference, NOT WORKING EXAMPLE):

    http://pastebin.com/Jua9Qsyp

    That shouldget you on the right path. One thing to notic is I'm not including any <head> information. This is being taken care of by the get_header() which pulls in header.php.

    Let me know if that all makes sense :)

  13. Digital Raindrops
    Member
    Posted 2 years ago #

    Also have a look at custom post types, this is an ideal candidate for custom post types, there are a number of plugins for custom post types, this plugin looks like it will do all you want "out the box", it is recently updated.

    That way you are not adding tables to the database and all the WordPress API functions are there to be used.

    Regards

    David

  14. yeagerc50
    Member
    Posted 2 years ago #

    Thanks for all of your comments guys. Looks like I've got some learning to do for sure. Firstly, I think I need a better understanding of how WordPress works. Can anyone recommend a good book that covers the basics and advanced stuff?
    Yeah, I know ....... the question has been asked a million times but I'd much rather get feedback from the people that have "been there done that" so I can get straight to the good stuff.

  15. Eric Hoanshelt
    Member
    Posted 2 years ago #

    I would look at codex.WordPress.org. It's free and written by the community.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.