Forum Replies Created

Viewing 15 replies - 301 through 315 (of 546 total)
  • Thread Starter syncbox

    (@syncbox)

    well, that is what I thought, though typically, if you have a category.php file and the logic says if (is_category())

    it IS going to use the category.php file

    So is_home() isn’t necessarily going to use index.php file if there is a page.php file AND home (start page) is the Page “home”

    So I will stick with the nested logic I came up with yesterday in my sidebar that allows me an “else” for pages and an “else” for everything else. Seems to work just fine.

    Thank you though, for taking the time to respond! It’s much appreciated and I’ve learned so much from reading your posts (not just to my questions, but all of them)

    Thread Starter syncbox

    (@syncbox)

    so, is_home() would mean you are using the index.php file even if your options are setting the start or home page to a Page?

    I found a way to get my sidebar to display the right thing anyway with some nested if else logic, but I’ll look into this too! Thank you!

    Thread Starter syncbox

    (@syncbox)

    Solved. Maybe not elegant, but working…

    I changed the way my sidebar logic operates, using two levels of conditionals… so that I could say else {} twice, once only if_page() and at the end… without specifying whether page or category or single (basically, if using the index page, since the only time it is ever used is when clicking one of the categories AND no posts exist)

    <?php
    if (is_page()) {
    if($post->post_parent) { // page is a child
    wp_list_pages(‘depth=1&sort_column=menu_order&title_li=&child_of=’.$post->post_parent);
    echo(”);
    }
    elseif(wp_list_pages(“child_of=”.$post->ID.”&echo=0″)) { // page has children
    wp_list_pages(‘depth=1&sort_column=menu_order&title_li=&child_of=’.$post->ID);
    echo(”);
    }
    elseif (is_page(11)) {
    echo (‘
    <p>stuff I want to show</p>
    ‘);
    }
    else { include (TEMPLATEPATH . ‘/file_i_want_to_show.php’);
    }
    }
    elseif (is_category()) {
    echo ‘<h2>Text title here</h2>

      ‘;
      wp_list_categories(‘title_li=&orderby=name&hide_empty=0&child_of=54&use_desc_for_title=0’);
      echo ‘

    ‘;
    }

    else {
    echo ‘<h2>Text title here</h2>

      ‘;
      wp_list_categories(‘title_li=&orderby=name&hide_empty=0&child_of=54&use_desc_for_title=0’);
      echo ‘

    ‘;
    }
    ?>

    seems to work, though I am sure it is not elegant… so if there IS some way to test for using the index.php file (when clicking a cat list link where the cat has no posts) and then displaying specific sidebar content, I’m still all ears. meanwhile, I’ll mark this resolved, since it seems to work.

    well, I’ve not upgraded because of the horrific “everything stops working” posts I’m seeing in the forum…

    1) maybe they are allowing html in the category description now (not filtering)
    2) Maybe you just aren’t calling the image properly so it simply doesn’t display?
    3) does the link reference stay in the content of the description and the html to display the image is removed when you revisit that category via Manage>Category by clicking the Edit link?

    I guess I’m asking if you think it’s not working because it actually removes what you put in the category description FIELD or you think it isn’t working because the image doesn’t show up.

    Just trying to help. Stripping of HTML in 2.2x annoyed the hell out of me until I fixed it using my suggestion above. As I said, I’ve been reluctant to upgrade just due to large number of wtf? posts about 2.3

    Um, couldn’t you use categories for the years instead of Pages?

    When a teacher posts, they simply choose which years their post(s) are relevant for… posts may be categorized under multiple categories.

    The layout for the page would use category.php assuming you have one or index.php if you don’t.

    Let’s say you list all the categories (which results in a list of years, as in

    2007
    2006
    2005
    2004 (etc)

    clicking that link would get posts from that category only, using the category.php or index.php file (you could create custom category-x.php files for each category id as well)

    a URL to the site in question would help. I think that you need to use categories, not Pages. WordPress Pages do not display posts.

    HTH

    yes… in:

    /wp-includes/default-filters.php around line #60 (at least, in v2.2x) look for:

    //add_filter('pre_category_description', 'wp_filter_kses');

    the // I put in front disables the filter from removing html tags and such in category_description

    HTH

    Hmmm… I’d use the c2c get custom field values plugin for this. You’d still do your custom field entries just as you currently are, but in the sidebar, rather than look for the post ID and such, you simply call that key’s entries. You can easily set it up to show in the sidebar ONLY if specific pages or categories, if desired. Let’s assume you are using a custom field named “news” and only want it to show when viewing home and news categories for purposes of this example:

    if (is_category('home') || is_category('news')) {
    echo '<ul>';
    echo c2c_get_custom('news','','','','');
    echo '/ul';
    }
    else {//do not show anything }
    ?>

    I think you could also write it this way:

    if (is_category('home') || is_category('news')) {
    echo "<ul>".c2c_get_custom('news','','','','')."/ul";
    }
    else {//do not show anything }
    ?>

    This doesn’t have to be in the loop to work.

    You can find the plugin at here and read about how to use it here.

    BTW, the empty parameters are explained in the plugin’s examples, but to put it quickly, they are
    ($field, $before=”, $after=”, $none=”, $between=”, $before_last=’, ‘, $limit=1, $unique=false, $order=’DESC’, $include_static=true, $show_pass_post=false)

    * $field : This is the name of the custom field you wish to display

    * $before : The text/HTML to display before all field value(s)

    * $after : The text/HTML to display after all field value(s)

    * $none : The text/HTML to display in place of the field value should no field value exists; if defined as ” and no field value exists, then nothing (including no $before and $after) gets displayed

    * $between : The text/HTML to display between multiple occurrences of the custom field; if defined as “, then only the first instance will be used

    * $before_last : The text to display between the next-to-last and last items listed when multiple occurrences of the custom field; $between MUST be set to something other than ” for this to take effect

    * $limit : The number of recent custom field values you want returned; default is 1

    * $unique : Boolean value (either ‘true’ or ‘false’) to indicate if only the latest instance of $field should be considered, and subsequent occurances of $field would be skipped in the search; default is ‘false’

    * $order : The order the results should be returned, either ascending/increasing (‘ASC’) or descending/decreasing (‘DESC’); default is ‘DESC’

    * $include_static : Boolean (‘true’ or ‘false’) to indicate if static posts (i.e. “pages) should be included when retrieving recent custom values; default is ‘true’

    * $show_pass_post : Boolean value (either ‘true’ or ‘false’) to indicate if passworded posts should be considered in the search; default is ‘false’

    HTH
    syncbox

    There’s nothing wrong with modifying the mark up of header.php… it’s not hacking – for information about wp_title, look here:

    There are several examples of how to use both bloginfo(‘name’) and wp_title() to get whatever results you want to see.

    So, no, what you are calling “page order” is not theme-dependent except that someone HAS “hacked” the header file per the wiki instructions. I’d refer to this as page and site TITLE order rather than page order… WordPress does have “Page” order functions that have absolutely nothing to do with what you want answers about…

    HTH

    syncbox

    Forum: Fixing WordPress
    In reply to: child_of

    some tags have echo functionality built-in, such as wp_list_pages() and wp_list_categories(); others don’t. Read this page for more detail:

    http://codex.ww.wp.xz.cn/Template_Tags/How_to_Pass_Tag_Parameters

    Thread Starter syncbox

    (@syncbox)

    thanks to MichaelH for a starting bit of code, I am using this:

    <ul id="catlist">
    <?php
    $categories = get_categories("title_li=&orderby=name&hide_empty=0&child_of=54");
    foreach ((array) $categories as $cat) {
    $cat_link = '<a href="' . get_category_link($cat->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $cat->cat_name) . '" ' . $rel . '>' . $cat->cat_name.'</a>';
    ?>
    <li><?php echo $cat_link . '' . $cat->category_description; ?></li>
    <?php
    }
    ?>
    </ul>

    to solve my needs. It works and because I have disabled the html stripping of category descriptions, I can style the paragraphs of the description as needed.

    I love WP. I love this forum!

    Actually, I’ve modified this… I stripped out the span and class and am taking advantage of the fact that I modified my functions file to stop html filtering (removing) in category descriptions. I put p tags in those, then set up a style for p tags when in a #catlist li

    ul#catlist li p {}

    works great and simpler, plus the p tags in the li tags check out as valid.

    Thanks, MichaelH! I was able to take your code as a starting point and get done what I wanted, which was to show a list of sub-categories for a parent category, with the category description of each below each bullet point! YAY!

    Here’s my code, in case others are interested in this solution:

    <ul id="catlist">
    <?php
    $categories = get_categories("title_li=&orderby=name&hide_empty=0&child_of=54");
    foreach ((array) $categories as $cat) {
    $cat_link = '<a href="' . get_category_link($cat->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $cat->cat_name) . '" ' . $rel . '>' . $cat->cat_name.'</a>';
    ?>
    <li><?php echo $cat_link . '<span>' . $cat->category_description; ?></span></li>
    <?php
    }
    ?>
    </ul>

    I set up styles for the span tags in ul#catlist li span {}

    to display:block; forcing the span (with the description) to be a new block.

    AWESOME. I love WP. I love this forum!

    You all rock!

    You can duplicate your index.php file and name it category-#.php for each cat that needs a different look, then just modify the html and css accordingly

    OR

    you can use php conditional statements to write dynamic html/styles in a single index or category file

    that’s it, really. You have to use one approach or the other. The simplest is the first option, but it makes keeping pages updated more difficult, imo.

    the second method is ideal, but requires real php skills and good xhtml/css skills to make use of WP’s dynamic functionality while addressing future flexibility of your site.

    CMS sites are best created using Pages…. but the issue is the same (maybe a bit simpler given the probability of less “post” or non-blog content)… you still have to make separate page templates or use conditional php to write the xhtml tags and classes/IDs you want based on WHICH page is requested.

    Most folks are overwhelmed by this if they are new to WP or don’t have the right skills – my first wp site has about 50 category-#.php files used depending upon the content. Most of my recent sites only use the page.php file in conjunction with the header, sidebar and footer files.

    You learn as you go!

    HTH
    Casey

    I posted there (in the Search Everything forum)… I’d be happy to test your beta version when you have one.

    If I could help, I would! But as I’ve said elsewhere, get this done and I’d be happy to send a donation!

    I use the search everything plugin (love it) but I need it to search the blogroll links and/or descriptions. Possible?

    I’d make a donation to see this working. Feel free to contact me offlist. syncbox AT gmail DOT com (do the obvious)

Viewing 15 replies - 301 through 315 (of 546 total)