WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Child theme - how to remove meta from some categories (9 posts)

  1. Halo Diehard
    Member
    Posted 1 year ago #

    First let me say: This is my first child theme, so if someone knows a better way to achieve this, I'm all ears :)

    I have a site that requires all meta data to be removed from almost all categories, say approximately 45 out of 50 categories.

    I have created a child theme to remove meta data from posts, and would like to now add in code to the style.css that will allow that meta data to show only for certain categories. (Or would I need to create a php file for those categories in my child theme?)

  2. Halo Diehard
    Member
    Posted 1 year ago #

    I found this and could try to use it, but I'm not sure exactly how I tweak it to show meta for those categories, or how to plug my category id's into it:

    $post_categories = wp_get_post_categories( $post_id );
    $cats = array();
    
    foreach($post_categories as $c){
    	$cat = get_category( $c );
    	$cats[] = array( 'name' => $cat->name, 'slug' => $cat->slug );
    }

    The language on the page is also beyond my scope atm: http://codex.wordpress.org/Function_Reference/wp_get_post_categories

    Please let me know if I'm posting this in the wrong place or if I need to supply more information. The child theme is for Twenty Eleven.

  3. Good Guy
    Member
    Posted 1 year ago #

    Perhaps you could post a link to your site and explain exactly what do you want to do.

    Good luck.

  4. Halo Diehard
    Member
    Posted 1 year ago #

    I have a site that requires all meta data to be removed from almost all categories, say approximately 45 out of 50 categories.

    As I stated, currently it is using a child theme that removes *all* meta data. I want the other five categories to show the meta data. (category, author, date)

    I prefer not to link to my site.

  5. Halo Diehard
    Member
    Posted 1 year ago #

    Why does it say wang7889 started this post?

    So, after hours of studying, I may be closer (I could really use some help...)

    It looks like I might want to put something like this in a php file (functions?), but I don't know if I have it right and I'm not sure which file.

    Again, I'm trying to only have meta-data (ie: author, date, category) show up in certain categories and not in others. This would be to only show meta-data in those categories whose id's are shown:

    function exclude_category_meta () {
    if ! in_category( array( 56,57,58,59,60,61,62,63,64,65) ) delete_post_meta }
    <?php exclude_category_meta() ?>

    Am I getting close?

  6. marsten
    Member
    Posted 1 year ago #

    Halo,

    I'm trying to do the same- did you get this to work?

  7. Halo Diehard
    Member
    Posted 1 year ago #

    Nope, didn't get anyone to help me and I've been studying it as new tweaks come up, but I still haven't figured out how to mess with functions.php and my child theme. Still have it set to remove all meta.

  8. thesaraheffect
    Member
    Posted 1 year ago #

    I'm having a similar problem, I only want to remove metatdata on specific categories. I am not sure if this will work for me: http://wordpress.stackexchange.com/questions/50961/removing-post-meta-from-category-pages

  9. esmi
    Forum Moderator
    Posted 1 year ago #

    Please post your own topic.

Topic Closed

This topic has been closed to new replies.

About this Topic