Jump to content
Sign in to follow this  
alisamski

Help with Omitting categories from blog recents

Recommended Posts

alisamski

Pagelines 1.3 (soon to upgrade) I want to be able to eliminate certain categories (3 of them) from the blog-recents on my home page... as I am adding separately in boxes and do not want it to double up on the page. Found this code, but there is only one category .. double checking before dumping in

// remove from home page
	function exclude_category($query) {
	if ( $query->is_home ) {
	$query->set(???cat??™, ???-11???);
	}
	return $query;
	}
	add_filter(???pre_get_posts??™, ???exclude_category??™);
	// remove from home page

where in function file can I put this? Can I add multiple categories in place of the '-11'? Thanks

Share this post


Link to post
Share on other sites
Simon

yes you can add multiple cats, like '-11 -2 -4' note, no seperator! the code should go in your platformbase functions.php

Share this post


Link to post
Share on other sites
alisamski

put in, but it white screened... is there a particular area inside the functions.php file it should go... I added at the very bottom both with a space between categories and no space between categories

Share this post


Link to post
Share on other sites
cmunns

sounds like syntax error. what's the exact code you added?

Share this post


Link to post
Share on other sites
alisamski

Put this in

/ remove from home page
	function exclude_category($query) {
	if ( $query->is_home ) {
	$query->set(???cat??™, ???-16 -17 -18???);
	}
	return $query;
	}
	add_filter(???pre_get_posts??™, ???exclude_category??™);
	// remove from home page

Share this post


Link to post
Share on other sites
Simon

`/ remove from home page` should be `// remove from home page` php comments are //

Share this post


Link to post
Share on other sites
alisamski

thought I had both... will try again once my theme problem stabilizes.

Share this post


Link to post
Share on other sites
alisamski

Did have it in.. same white screen.. Entire function.php code. Where do I add?

<?php
	
	// Setup  -- Probably want to keep this stuff...
		// Set up action for section registration...
		add_action('pagelines_register_sections', 'base_sections');
	
		/* Hello! First, lets load the PageLines core so we have access to the functions */
		require_once(TEMPLATEPATH . "/core/core.init.php");
	
		// For advanced customization tips & code see advanced file.
		//--> require_once(STYLESHEETPATH . "/advanced.php");
	
	// ====================================================
	// = BASE FUNCTIONS - Where you should add your code  =
	// ====================================================
	
	// ADDING CUSTOM SECTIONS ------- //
		// Register a Drag&Drop HTML Section for the admin.
		// A pullquote section was created here for demonstration purposes
	
		// Sections should be named: section.[your section name].php and placed in the sections folder.
	
		function base_sections(){
	
		/*
			Your custom sections get registered in here...
			PageLines Register Section Arguments:
				1. Section Class Name,
				2. Directory name (or filename if in root of 'sections' folder),
				3. Init Filename (if different from directory name),
				4. Section setup and variable array
	*/
	
			pagelines_register_section('BasePullQuote', 'pullquote', null, array('child' => true) );
			pagelines_register_section('BaseSidebar','sb_base', null, array('child' => true) );
	
		}
	
	// ABOUT HOOKS --------//
		// Hooks are a way to easily add custom functions and content to the Platform theme. There are hooks placed strategically throughout the theme
		// so that you insert code and content with ease.
	
	// HOOKS EXAMPLE --------//
		// Below is an example of how you would add a social media icon to the icons in header (branding section)
		// We have placed a hook at the end of the icon set specifically add new icons without modifying code or having to worry about your edits
		// getting thrown out during the upgrade process. The way to use hooks goes a little like this:
	
		// add_action('hook_name','function name');
	
		// ---> uncomment to load
		add_action('pagelines_branding_icons_end', 'add_icons_to_branding');
	
		// function name
		function add_icons_to_branding(){
			// This hook adds a stumbleupon icon to the header of your theme. The class referenced in the link can be seen in the style.css
			// and is the image from the CSS is placed in the images folder
			?>
			
		<?php }
		// end function
	add_action('pagelines_before_branding_icons', 'new_search');
	
	// function name
	function new_search(){
	get_search_form();
	}
	
	// ADDING NEW TEMPLATES --------//
		// Want another page template for drag and drop? Easy 
		// 			1. Add File called page.[page-id].php to Base
		// 			2. Add /* Template Name: Your Page Name */ and Call to 'setup_pagelines_template();' to that file (see page.base.php)
		// 			3. Add 'pagelines_add_page('[page-id]', '[Page Name]');' to this functions.php file
	
		// Add Base Page
		pagelines_add_page('base', 'Custom Page');
	
	// OVERRIDE SECTION TEMPLATES --------//
		// Want more customization control over any of the core section templates in PlatformPro? Just override the template file.
		// To do that, just add a file called template.[section-id].php to this child theme and it will override the section templates
		// for the section with that ID.  For example, template.boxes.php will override the boxes templates.
		// Once overridden you can copy the code from that section, paste it there and edit to your heart's content. [/code]

Share this post


Link to post
Share on other sites
timlinson

I would put it above the `// ADDING NEW TEMPLATES --------//` line, but that's not a hardset requirement.

Share this post


Link to post
Share on other sites
alisamski

That's where I put it in last time.. Do I need an //end function before // ADDING NEW TEMPLATES? Sorry, not too savvy here.

// function name
	function new_search(){
	get_search_form();
	}
	
	// ADDING NEW TEMPLATES --------//

Share this post


Link to post
Share on other sites
alisamski

This is what I did....

// function name
	function new_search(){
	get_search_form();
	}
	
	// remove from home page
	function exclude_category($query) {
	if ( $query->is_home ) {
	$query->set(???cat??™, ???-16 -17 -18???);
	}
	return $query;
	}
	add_filter(???pre_get_posts??™, ???exclude_category??™);
	// remove from home page
	
	// ADDING NEW TEMPLATES --------// 

Share this post


Link to post
Share on other sites
Simon

when you get white screened is there a file error_log produced anywhere? can be in the theme folder or wordpress root folder, also make sure there a NO blank lines at the end of the file and it does NOT end with `?>`

Share this post


Link to post
Share on other sites
alisamski

no error logged.. it just turns white. Tried to find an error on server... no dice. I've made changes to the functions.php file before without any problems.. Just doesnt like it once it whites out.. have to re-upload the functions.php

Share this post


Link to post
Share on other sites
Simon

send the broken file to simon@pagelines.com

Share this post


Link to post
Share on other sites
alisamski

Sent. Thank you for looking at it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×