Viewing 5 replies - 1 through 5 (of 5 total)
  • first question:

    <?php
    $current_cat_name = single_cat_title('',false);
    $page = get_page_by_title($current_cat_name);
    if($page) : //only do the following if a page with this title exists
    $pageid=$page->ID;
    query_posts('post_status=publish&page_id='.$pageid);
    if(have_posts()) : while(have_posts()) : the_post();
    /*your page output code here*/
    the_title();
    the_content();
    endwhile;
    endif; //end of the loop
    wp_reset_query();
    endif; //end of if($page)
    ?>

    http://codex.wordpress.org/Template_Tags/single_cat_title
    http://codex.wordpress.org/Function_Reference/get_page_by_title
    http://codex.wordpress.org/Function_Reference/query_posts#Post_.26_Page_Parameters
    http://codex.wordpress.org/Function_Reference/wp_reset_query

    second question:
    you seem to have ignored the sequence of opening/closing php tags:
    instead of this line:

    $postslist = get_posts('numberposts=5&order=DESC&orderby=ID&category=<?php echo get_post_meta($post->ID, 'identity', true); ?>');

    you could try to use:

    $postslist = get_posts('numberposts=5&order=DESC&orderby=ID&category='. get_post_meta($post->ID, 'identity', true));

    Thread Starter deepwhitesound

    (@deepwhitesound)

    you are beyond incredible. thank you so much! the second code, i knew i was doing something wrong but i am new to this code and didn’t know exactly what it was.

    thanks again you just saved the day

    Thread Starter deepwhitesound

    (@deepwhitesound)

    actually, for the first code, how about calling up just a link to the page with the same title, rather than the content from that page?

    i’d like to insert code that would call up the content from a page with the same name as the category name.

    it is not absolutely clear to me what that means;
    however, if you just want to have a link to that particular page there:

    <?php
    $current_cat_name = single_cat_title('',false);
    $page = get_page_by_title($current_cat_name);
    if($page) : //only do the following if a page with this title exists
    $pageid=$page->ID; ?>
    <a href="<?php echo get_permalink($pageid);?>"><?php echo $page->post_title; ?></a>
    <?php
    endif;
    ?>

    this outputs the linked title of the page with the same name as the category.

    Thread Starter deepwhitesound

    (@deepwhitesound)

    everything you have provided works perfectly 🙂 thank you so much

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘help with custom field data’ is closed to new replies.