vary post order per category page

Community Forums Forums Design Tips and Tricks vary post order per category page

This topic is: not resolved

This topic contains 8 replies, has 2 voices, and was last updated by  braddalton 1 year, 2 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #59453

    chrismc
    Participant
    Post count: 5

    Hi,

    I am trying to display posts in a different order on different category pages. I have tried various plugins that offer a drag and drop ability to reorder the posts but have found them to be buggy and the order does not stick. I have found one – My Post Order which seems to do the job. It produces sections that can be added into templates.

    I have successfully achieved the reordering by adding the following code:

    add_action('wp_head', 'custom_change_posts_order');
    function custom_change_posts_order() {
        global $query_string;
    	
        if (is_category('mentors')) { 
    
            $posts = query_posts('section_name=mentors');		
        }
    	else if (is_category('speakers')) {
            $posts = query_posts('section_name=speakers');
        }
    	else  if (is_category('steering-group-people')) {
            $posts = query_posts('section_name=steering');
    	}	
    }

    However, doing this stops the category archive headline and intro text from displaying. How can I get the heading and intro text back?

    Many thanks

    #59463

    braddalton
    Participant
    Post count: 10342

    You could echo in the text directly or create widget areas above all category archive pages


    #59469

    chrismc
    Participant
    Post count: 5

    Ok, many thanks – have decided to go the widget route.

    #59475

    chrismc
    Participant
    Post count: 5

    Actually it still doesn’t work.

    I’m using the Dynamik child theme to build the site and have tried creating a widget area and used custom conditionals to tell it to show only on certain category pages (and tried it using the ‘Display Widget’ plugin too) but I can’t get the widgets (or any hooks) to only display on the category pages I want. I can get them on all or none.

    It seems the $posts = query_posts(‘section_name=mentors’); has taken out too much.

    #59486

    braddalton
    Participant
    Post count: 10342

    You can easily change the is_home() conditional in this code to the is_category() conditional as well as the hook position:

    Please copy the code from the view raw link and
    paste it at the end of your child themes functions.php file
    using a text editor like Notepad++


    #59557

    chrismc
    Participant
    Post count: 5

    Many thanks but this just produces php errors – I’ll head back to the Dynamik forum.

    Again, many thanks

    #59621

    braddalton
    Participant
    Post count: 10342

    Sometimes when you copy the code, the Apostrophes can turn around causing errors.

    Link to your site please.

    The code is tested and works perfectly. Did you modify the code in anyway?


    #59857

    chrismc
    Participant
    Post count: 5

    It turns out there was a plugin conflict (display widgets).

    I have solved the problem with some custom hooks inserted into templates for the categories (Dynamik makes this kind of thing easy – just so many config options it gets a bit confusing but got there in the end.

    Many thanks for your help @Brad

    Chris

    #59865

    braddalton
    Participant
    Post count: 10342
Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.