1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Is this possible with Wordpress?

Discussion in 'PHP' started by I. Brian, Jun 26, 2007.

  1. #1
    Is it possible to edit the PHP in Wordpress templates so that specific graphics will appear in specific categories according to what the category is?

    I had tried using this a long time ago, but it no longer appears to work:

    
    <?php if(is_home()) include('navbar1.php');
    elseif(is_category('Carrots') ) include('navbar2.php');
    elseif(is_category('Puppies') ) include('navbar3.php');
    elseif(is_category('Lemons') ) include('navbar4.php');
    elseif(is_single()) include('navbar5.php');
    elseif(is_page())include('navbar6.php'); ?>
    
    Code (markup):
    Also, would it likely be possible to add an include (such as for an image) whenever the posting author is a specific user? Ie, to include a user image whenever that user publishes a post?

    One last thing. :)

    Is it possible to display an except of a Wordpress post using PHP, that still allows any first image included in the post to actually display beside the excerpt? Simply that at present any post images are stripped out of the post.

    Am I being too ambitious asking these questions, or simply displaying my inexperience with editing PHP?

    :)
     
    I. Brian, Jun 26, 2007 IP
  2. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #2
    it can definitely be done. i'm not familiar with wordpress enough to tell you how to go about it, but it can definitely be done as wordpress is powered by php.

    might want to try encapsulating your conditionals in curly braces. might help some.

    
    <?php
        if(is_home())
        {
             include('navbar1.php');
        }
        else if (...)
        {
             .....
         }
         else
         {
             .....
         }
    ?>
    
    PHP:
    now, you dont need to have the curly braces technically if you're only doing 1 thing in the conditional. i know it will do the line directly following the conditional but im not sure about on the same line.
     
    ansi, Jun 26, 2007 IP
  3. dankenpo

    dankenpo Guest

    Messages:
    30
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Go over the files of the WordPress theme you want to edit and study how it controls your blog’s appearance. Take note of how the pages, index.php (for the main page) and single.php (for individual blog posts), call the different template files.

    The header is called first. What is called next depends on the WordPress theme you are using: some call the main content next then the sidebar then the footer. Other themes call the sidebar first then the main content and then the footer.

    Create a new folder and copy into it 1.) the style.css of the WordPress theme you want to edit, and 2.) the folder containing the images.

    Create a new HTML document in Dreamweaver and save it into the folder you’ve just created. Go to Code View and paste into it these lines:
    
    [COLOR="Olive"]<!-- Header part goes here --> <!-- /Header part ends here
     --> <!-- Main content here --> <!-- /Main content ends here --> <!-- 
    Sidebar content here --> <!-- /Sidebar content ends here --> <!-- Footer
     content here --> <!-- /Footer content ends here -->[/COLOR]
    
    Code (markup):
    The lines are code comments to guide you as you copy code from the different PHP files for editing and transfer these back again after you’ve finished customizing the design. Just re-arrange the lines if the WordPress theme you want to customize calls, for example, the sidebar before the main content.

    Start copying codes from the different template files: the header.php, sidebar.php and footer.php. For the main content, copy the code that displays your blog content in index.php. The first thing you need to change is the location of the CSS file in the header. WordPress themes point to the CSS file using the line:
    
    <link rel="stylesheet" type="text/css" media="screen" href="<?php 
    bloginfo('stylesheet_url'); ?>" />
    
    Code (markup):
    Just change
    <?php bloginfo('stylesheet_url'); ?>
    Code (markup):
    to
    style.css so that your document can locate the stylesheet.

    After that, change the dynamic calls for such things as your blog name and sub-title and add dummy headlines and article text.

    Most WordPress themes that display the blog title as text have the following code:
    
    <h1><a href="<?php echo get_settings('home'); ?>/">
    <?php bloginfo('name'); ?></a></h1>
    
    Code (markup):
    What this does is display your blog name and link it to your main page. To view how the blog name is rendered, just delete <?php bloginfo('name'); ?> and type in your blog name. Do the same thing for the blog tagline or subhead, which is displayed by the code <?php bloginfo('description'); ?>.

    To read more, visit http://max.limpag.com/2006/06/07/how-to-edit-wordpress-design-using-dreamweaver/

    Enjoy!
     
    dankenpo, Jun 26, 2007 IP