Jump to content
Sign in to follow this  
trisquelmedia

Filter post category in blog page, is possible in Pagelines?

Recommended Posts

trisquelmedia

Hi:

 

I have a blog page where i want to show certain categories of post, is possible in Pagelines Framework? if the answer is no, will you implement in future versions of Pagelines Framework?

 

Else, could you recommend me pagelines compatible plugins with this funcionality?

 

Thxs!

 

Regards

Share this post


Link to post
Share on other sites
trisquelmedia

i.e, this code:

 

<?php
if ( is_home() ) {
	query_posts( 'cat=-3' );
}
?>

 

The tutorial says that this code should be introduced in index.php, my pagelines base theme dont hace index.php , suffice to create index.php and add that code?

Share this post


Link to post
Share on other sites
trisquelmedia

if i want to applicate this rules in blog page and inside pages, where i introduce this code?

 

Thxs!

Share this post


Link to post
Share on other sites
trisquelmedia

hi:

 

i founded a code that should serve me. I use it in the blog page, but it dont filter any category, it shows all the post, anyone know why?

 

This code is added in functions.php on the base theme, 9 is the category id

 

Front Page is a static page so that Home Page is the Blog Page according wp codex

 

//Removes certain categories from home page based on category id
add_action('pagelines_loop_after_post_content' ,'filter_cats');
function filter_cats(){
    if (is_home()){
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; //fixes pagination
        $args = array(
            'cat'=> '-9',
            'paged'=> $paged
        );
        query_posts($args);
      }
}
 
why is it ignoring this filter?

Share this post


Link to post
Share on other sites
trisquelmedia

hmm in the forum, only that i think that is code is valid for Platform Pro

 

I only sustitute the hook, the original code was:

 

//Filtrado de categorias segun la pagina   
        add_action('pagelines_inside_top_theloop' ,'filter_cats');
        function filter_cats(){
                if (is_home()){
                        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; //fixes pagination
                        $args = array(
                                'cat'=> '-5',
                                'paged'=> $paged
                        );
                        query_posts($args);
                  }
        }

 

Is there any way to do the same thing in pagelines framework?

Share this post


Link to post
Share on other sites
trisquelmedia

I have found another code of anthalis developer

, that works in pagelines framework

 

   //Removes certain categories from home page based on category id
//Filtrado de categorias segun la pagina   
add_action( 'pre_get_posts', 'exclude_category' );
function exclude_category( $query ) {
    if ( $query->is_home ) {
        $query->set( 'cat', '-9' );
    }
}

 

Perfect!

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  

×