Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Read this link ->
    http://thedeadone.net/forum/?p=418#comment-1542

    <?php
    /* assuming you have called the custom field key “name”… */

    $post_title = get_post_meta($post_id, ‘name’, true);

    $postdata = array(
    “ID” => $post_id,
    “post_title” => $post_title;
    sanitize_post($postdata,”db”);
    wp_update_post($postdata);
    ?>

    Forum: Plugins
    In reply to: Linking categories to pages

    you would use templates for individual pages in 2.8.

    if you create a “mypagetemplate.php” file in your theme folder and place at the very top of this file – this code:

    <?php
    /*
    Template Name: mypagetemplate.php
    */
    ?>

    wordpress automatically interprets it as a template file that you can assign to individual pages.

    (tip: copy paste the index file code into your template, just to have something to work with…)

    This page may then be filtered for different categories by using either query_posts calls or in_category calls in the template file.
    read the help files for each function.

    it is all very clear as sausage water 😉

    *edit: There is a strong reason to use query_posts instead of in_category, because ‘the loop’ still counts up using the in_category call, and if you have 10 non category in a row, your page won’t display anything, while the query_post will display a clean 10 post regardless, (if that is your setting) everytime and anytime…

    sorry about that!
    lost the category filtering due to a typo in the code above…

    this:
    $querystring = 'cat='. $submissions.','.$inspiration.','.$finalist.','.$offset;

    should be this:
    $querystring = 'cat='. $submissions.','.$inspiration.','.$finalist.$offset;

    I was filtering posts on a single page with the function call ‘query_posts’ and noticed after a while the same problem as the original poster (Dunkkan) – the unabillity to sift through older and newer posts with the next_posts_link or previous_posts_link call, and it was easily addressed to the query_post function, since if I turned it off, everything worked fine.

    this seems to solve it. I’m not sure for how long though, since I’m quite novice to php and wordpress altogether. I make of use of the get_query_var and dynamically add the appropriate paged number to the offset variable.

    <?php
        //get the categories...
        $submissions = get_cat_ID( 'submissions' );
        $inspiration = get_cat_ID( 'inspiration' );
        $finalist = get_cat_ID( 'finalist' );
        $crew = get_cat_ID( 'crew' );
    
    	if(intval(get_query_var('paged'))>1){
    		$offset = '&offset='.((get_query_var('paged')-1)*10);
    	}else{
    		$offset = '&offset=0';
    	}
    
    	$querystring = 'cat='. $submissions.','.$inspiration.','.$finalist.','.$offset;
    	?>
    
        <!--begin query-->
        <?php query_posts($querystring.'&showposts=10'); ?>
    
    	<?php if (have_posts()) : ?>...
    
    ...<?php endif; ?>
    
        <!--end query-->
        <?php wp_reset_query(); ?>
Viewing 4 replies - 1 through 4 (of 4 total)