Forum Replies Created

Viewing 15 replies - 31 through 45 (of 74 total)
  • Thread Starter adieu

    (@adieu)

    I just tried this:

    'cat' => hu_get_option('featured-category', '-16')

    But it showed the page as if nothing was changed. 16, or News, appeared in the most recent post.

    • This reply was modified 8 years, 5 months ago by adieu.
    Thread Starter adieu

    (@adieu)

    I checked and unchecked the option, but nothing seems to change. I would rather not display the featured post in the list below, but I guess it’s not the end of the world if it does.

    I wonder if I might have removed important code when I edited featured.php.

    This is how it read:

    $featured = new WP_Query(
    	array(
    		'no_found_rows'				=> false,
    		'update_post_meta_cache'	=> false,
    		'update_post_term_cache'	=> false,
    		'ignore_sticky_posts'		=> 1,
    		'posts_per_page'			=> hu_get_option('featured-posts-count'),
    		'cat'						=> hu_get_option('featured-category')
    	)
    );

    I changed it to:

    $featured = new WP_Query(
    	array(
    		'no_found_rows'				=> false,
    		'update_post_meta_cache'	=> false,
    		'update_post_term_cache'	=> false,
    		'ignore_sticky_posts'		=> 1,
    		'posts_per_page'			=> hu_get_option('featured-posts-count'),
    		'cat'						=> ('-16')
    	)
    );

    Thinking I might have deleted important information in the editing, I tried a couple variations of:

    'cat' => ('-16') hu_get_option('featured-category')

    But my home page was wiped blank.

    • This reply was modified 8 years, 5 months ago by adieu.
    Thread Starter adieu

    (@adieu)

    Hi bdbrown,

    Not sure if it is what I have been doing or the settings I’ve changed, but now on my home page I have two copies of the most recent post.

    But it only shows it posted once on my dashboard.

    Any idea about that?

    Thread Starter adieu

    (@adieu)

    Works perfectly, bdbrown. Thanks. You’re the best.

    Thread Starter adieu

    (@adieu)

    Yes, last post means most recent…

    I have six categories that I would like to appear in the featured posts, but maybe I could give them all one such as “cruising” or “featured”, and a second category to distinguish them.

    I like the second option. I copied featured.php to my child theme. I would like to exclude all “news” category posts which will be 16 and have them appear in the second sidebar.

    Admit that I am clueless about how to code that.

    Googling tells me that I can add this to index.php

    if ( is_home() ) {
        query_posts( 'cat=-3' );
    }

    to exclude posts, but I have copied index.php to my child theme and tried placing the code in a couple places. Nothing happened that I could see (using the numbers of a couple of my categories).

    • This reply was modified 8 years, 5 months ago by adieu.
    Thread Starter adieu

    (@adieu)

    Thanks bdbrown. Feeling a bit foolish that I forgot the negative sign in all my attempts. It was right in front of me.

    Is this what you mean?

    function my_exclude_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '-16' );
        }
    }
    add_action( 'pre_get_posts', 'my_exclude_category' );

    If I exclude posts such as ‘-14’ which is the ‘Puget Sound’ category, all the Puget Sound posts will disappear except the last post which is associated with the main photo and the excerpt.

    Is there an easy way to block posts from appearing there as well? If not, maybe I could use a reorder plugin to each time shuffle a ‘News’ category post out of the last spot so it does not appear in the main content area, or does so only briefly. That make sense?

    Your help is much appreciated. Have a good night. I am about to do the same.

    Thread Starter adieu

    (@adieu)

    If I place this in the functions.php file on my site:

    function exclude_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '6' );
        }
    }
    add_action( 'pre_get_posts', 'exclude_category' );

    Then only category ‘6’ posts appear in the main blog. All the other categories are excluded, except the last post that is associated with the main photograph. It remains. On my site, category ‘6’ is the “Georgia Strait and Sunshine Coast” category.

    The category I would want to exclude is News, which is 16. I have not yet created any News posts. If I place

    function exclude_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '16' );
        }
    }
    add_action( 'pre_get_posts', 'exclude_category' );

    in functions.php, no posts appear in the main blog, except for the one associated with the main photo.

    Any ideas what I am doing wrong?

    Thread Starter adieu

    (@adieu)

    Maybe I’ve figured it out. I’ve get back to you either way. :-}

    Thread Starter adieu

    (@adieu)

    Hi bdbrown,

    It easy enough to use the Hueman Posts widget to define a particular category. I have done that already with another category.

    My problem is translating the code below.

    function exclude_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '-1,-1347' );
        }
    }
    add_action( 'pre_get_posts', 'exclude_category' );

    I don’t know how they have determined the category ID numbers 1 and 1347. I must be crazy, but have looked everywhere and not found any numbers to identify my categories.

    • This reply was modified 8 years, 5 months ago by adieu.
    Thread Starter adieu

    (@adieu)

    Thanks tons, bdbrown.

    The news posts will have the same category. I will read up on the link you gave me.

    Cheers

    Thread Starter adieu

    (@adieu)

    I think that did it.

    https://wp.me/P7AeN3-gA

    Much appreciated. You’re the best.

    Will get back to you if the borders and shadows bother me.

    Many thanks.

    Thread Starter adieu

    (@adieu)

    Hi

    You can find a page here.

    https://wp.me/P7AeN3-gA

    Thread Starter adieu

    (@adieu)

    The problem is that if I create a sample page it seems to affect all other pages on the site. Is there a way to apply your instructions without it affecting other pages?

    I select the full page view.

    In Appearance/Edit CSS I place:

    .container-inner {
    max-width: 900px;
    }

    and click “save stylesheet”.

    I also tried to save your code in my child theme, but nothing happened ??

    This is a screenshot of my homepage with your code.

    Thread Starter adieu

    (@adieu)

    That’s interesting. I like the way yours works!

    Tried it again. Same result as before

    I will keep trying things. Maybe there is something I am doing wrong.

    Thanks for your help.

    Thread Starter adieu

    (@adieu)

    Hi bdbrown,

    It doesn’t seem to work.

    Pages without columns view correctly, except there are gray boxes where the (removed) sidebars would appear if there were sidebars.

    Pages will sidebars are squeezed down so the whole page is 900px wide. The content area is a skinny column down the middle.

    Thanks for the help.

Viewing 15 replies - 31 through 45 (of 74 total)