Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1146799
    necxelos
    Participant

    Once more, a quick disclaimer:
    – I don’t have a domain yet, so I work on localhost, thus can’t provide site access. I will try my best o make my questions as specific as possible.
    – I have a Child Theme ready to go. I used the one downloadable from Your site.
    – I’m using Integrity stack for now although I’m not sure if I’ll stay loyal to it or change it to Ethos. Please try to give answers as stack-independent as possible.

    (Please, if possible, use my post structure so I can easily find what is what)

    1. How can I have one group of “posts” look totaklly different from all the other? What I’m aiming for is “Quote of the Day” very thin content without title or Read More functionality but with individual background (each Quote having it’s own)?

    2. I wanted to style my articles separately based on category they belong to. I found this guide:

    http://code.tutsplus.com/tutorials/style-different-categories-in-your-wordpress-site-differently-using-css–cms-23687

    …which basically solves the problem but with just few small issues:
    a) Is it the proper (optimal in terms of performance) way to do it? Just a confirmation or negation please.
    b) How can I target posts using parent categories? Dozen child categories will (in my case) exist only for organisational purposes, but I need styling only based on 3-4 parent categories.

    3. Is there any way to get “related posts” functionality or something similar to that? What I need is to be able to set (manualy) which already published posts are related to the newly created one, and have those related presented at the bottom of a post in form of very minimalistic Title + Excerpt boxes. So no automatic search for related posts required, just the matter of clean presentation and avoiding manual rewriting of gazilion links when I decide to change URL structure for some reason.

    4. Is filterable index unique to Ethos or can I use it in other stacks too? Can I set this filterable index to use manualy chosen Tags instead of Categories?

    Thanks in advance and good day to You all 🙂

    #1147316
    Rad
    Moderator

    Hi there,

    Thanks for posting in.

    1. It can be done through CSS and post format selectors, and it largely depends on your required design. Since there is no mockup design and URL to check, I can’t really tell the required CSS.

    2. a. CSS is the only way to change a site’s styling, hence, there is no other way. Unless you’re trying to change the structure which requires template editing.

    2. b. There is no such feature, but some user is able to do it, please check this https://wordpress.org/support/topic/add-name-of-top-level-catgory-to-body-class

    Then you can select it through category slug, eg. body.category-slug-here

    3. You may try this https://wordpress.org/plugins/wordpress-23-related-posts-plugin/, jetpack plugin has the same feature too.

    4. It’s only available on Ethos stack, and sure, you can change it to tags filter. Please edit this file \wp-content\themes\x\framework\views\ethos\_index.php and move it to your child theme (eg. \wp-content\themes\x-child\framework\views\ethos\ )

    Replace this line,

    $categories = get_categories( array( 'include' => x_get_option( 'x_ethos_filterable_index_categories' ) ) );

    with this,

    $categories = get_tags( array( 'include' => x_get_option( 'x_ethos_filterable_index_categories' ) ) );

    then replace this line,

    $wp_query = new WP_Query( array( 'post_type' => 'post', 'paged' => $paged, 'cat' => $category->term_id ) );

    with this

    $wp_query = new WP_Query( array( 'post_type' => 'post', 'paged' => $paged, 'tag_id' => $category->term_id ) );

    Hope these helps.

    #1149180
    necxelos
    Participant

    1. Something along those lines:
    http://cdn-media-1.lifehack.org/wp-content/files/2010/10/quote-H.-Jackson-Brown-Jr.-h-jackson-brown-jr-wind-sails-43.png
    With intended features:
    – Image as background (preferably using the featured image to avoid setting up background image in CSS everytime I post new quote).
    – Big text with the actual quote in it and author line below (different fonts).
    – No option to enter single post whatsoever (I want this “post” to be visible as a whole and only on blog page, category archive or tag archive pages (if it belongs to a category or a tag of course).
    – Should be far thiner than standard post.

    2. a) Awesome, if this is the right way to go then it’s easier then I thought. Great 🙂
    2. b) Ok, this topic looks like it has what I need. But sadly I’ve got no idea where to put this code. I paste the code below for reference:

    // Add specific CSS class by filter
    add_filter('body_class','top_cat_body_class');
    
    function top_cat_body_class($classes) {
    if( is_single() ) :
    	global $post;
    	$cats = get_the_category( $post->ID );
    	if( count( $cats ) > 1 ) {
    		return array('genericClass');
    	}
    	else {
    		$cat_anc = get_ancestors( $cats[0]->term_id, 'category' );
    		$top_cat = array_merge( array($cats[0]->term_id), $cat_anc );
    		$top_cat = array_pop( $top_cat );
    		return array(get_category($top_cat)->slug);
    	}
    elseif( is_category() ) :
    	$cat_anc = get_ancestors( get_query_var('cat'), 'category' );
    	$top_cat = array_merge( array(get_query_var('cat')), $cat_anc );
    	$top_cat = array_pop( $top_cat );
    	return array(get_category($top_cat)->slug);
    else :
    	return $classes;
    endif;
    }

    3. Checked Zemanta Related Posts and Jetpack and those are completely the opposite of what I need to do. Those plugins search (automatically – no manual control over it) first my site then the web for related posts then they let me pick (only from the list presented to me) which posts I want to include as related. Not to mention both of those require connection to some external services (wordpress domain blogs for example). And of course they are for English posts only (another downside of automatism) which is a total Buzzkill (I’m from Poland and I expect to write posts in Polish most of the time – at least at the beginning).

    I need something gazilion times simpler. When I write new article (or edit old one) I want to be able to choose, from my own articles list, ones that I feel might interest the reader of current one and present them at the bottom as micro-excerpts/thumbnails (clickable as links).

    The only two reasons I don’t want to just post several links at the bottom of an article (and maybe stylize those with CSS or shortcodes) are:
    – I want the Thumbnail-ish/Excerpt-ish form of presenting those related articles, because it just looks better and gives an overview of “what’s in this related article”.
    – I don’t want to rewrite all those links in every article if I happen to change my URL’s for example.

    Any suggestions/recommendations? I googled through some related post-ish plugins but they rarely mention if plugin uses some crazy algorithm to “relate” posts from the web, random blogger community, etc. or just allows for manually picking posts from my own site.

    4. Another function exclusive to Ethos… If I may expand my question here:
    – There are lots of unique functionalities Ethos have that other stacks don’t, but are there any functionalities exclusive to other stacks? Or other stacks just offer different form of presentation without any exclusive features whatsoever? Is Ethos some kind of a super-stack in X Theme?

    Thanks again 🙂

    #1149333
    Rue Nel
    Moderator

    Hello There,

    Thanks for the updates!

    1] As this is all custom development, regretfully we won’t be able to assist further. Custom development is outside the scope of our support. We’re happy to provide advice and get you started in the right direction, but you would still be responsible for the implementation.

    2] What you are trying to accomplish requires a template customization, we would like to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices. After the child theme is set up, you can add that code in your child theme’s functions.php file.

    3] Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.

    Please try out the WordPress repository: https://wordpress.org/plugins/search.php?q=related+post

    4] Each of the stacks has a unique design and features like the carousel, slider, post meta, title icons, category sub titles and more. Ethos stack is not super stack it just the stack that has the blog rich features. Other stack is more good for corporate website.

    Thank you for your understanding.

    #1149615
    necxelos
    Participant

    1. Fair enough. Can You at least tell me a way to apply following changes to posts from one chosen category:
    a) Make featured image a background image of a post (I know it’s done in Ethos, so there have to be code for this)?
    b) Disable all Read More equivalent links in a post (disable link in featured image, disable link in title)?
    And I’ll try to do the rest myself from there.

    2. If I understood correctly this code should add new class (parent category class) to my <article id=”” class””> which sounds great. But either I did something wrong or it doesn’t work because when I inspect my article with FireBug I don’t see any class being added there (except for the one that was there before).

    BUT

    I found this:

    function rats_class($classes){
     global $post;
     $cat=get_the_category(get_query_var('post'));
     if(is_array($cat)&&!empty($cat)){
      if($cat[0]->category_parent!=0){
       $parents=get_category_parents($cat[0]->term_id,false,'@',true);
       if(!empty($parents)){
        $parent=explode('@',$parents);
        $classes[]='category-'.$parent[0];
       }
      }
     }
     return $classes;
    }
    add_filter('post_class','rats_class');

    Which seem to work. Only thing I need is for this function to add not only highest level parent but all level parents (I will have several levels of parent-children categories). How do I need to edit this code to achieve this?

    Also: is this code safe (it’s not the one from You guys)? Sadly I couldn’t tell even of there was an A-Bomb symbol there.

    3. No, no, no, I didn’t ask for customization here. I just wanted to know if You can recommend me (based on Your customers reviews or Your own knowledge “that it works”) a plugin that will do what I need (specification in my previous post) and won’t break the X Theme itself (as amateur plugins tend to break stuff a lot from what I heard).

    4. That wasn’t an accusation, not by a long shot. I’m sorry if You felt that way. Quite the contrary, I think the Ethos stack might be the best stack ever 🙂

    But to make a decision of changing from Integrity to Ethos I need to have all the data which is:
    – List of functionalities* that Ethos have and other Stacks don’t (like for example Featured Post or Filterable Index).
    – List of functionalities* that other Stacks have and Ethos don’t.
    *By functionalities I mean something that can’t be recreated using CSS or shortcodes (like for example Ethos Carousel which of course is 999 times more optimized then Revolution Slider but I can make Revolution Slider look exactly the same). I just need to know what I’m giving up and for what if I decide to choose Ethos over Integrity.

    Again thanks in advance for answers and understanding 🙂

    #1149947
    Rad
    Moderator

    Hi there,

    1. Maybe possible with jQuery, but would you mind providing your site’s URL? You can pick up any demo URL since I’m not sure which stack you’re on. Is it recent posts or just blog posts?

    2. The get_category_parents() already do that, https://codex.wordpress.org/Function_Reference/get_category_parents try adding the single parent category instead of multiple categories. There is no way to tell if it’s top-most parent, you can only assume that it’s the root parent since you manually assigned it. Look for the class that matches your manually assigned root parent.

    3. It’s a quite big development, there are some plugins but may not work on your requirement. I can’t fully remember them, though, custom development can’t be avoided to make it work to your preference. I can’t really tell, you may want to consult it to a developer for a proper estimate (time, difficulty, and such).

    4. Yes, there are features that are only available on each stack. You can find them at our knowledge base under Customizer section. Example, https://community.theme.co/kb/customizer-ethos/

    Thanks!

    #1149958
    necxelos
    Participant

    1. Using Integrity still and also still on localhost. I’m talking about main content blog posts (not single article) and main content category or tag archives (also not single article). And to get the desired “Quote of the Day” type of post all I need is basically:
    – A lot of CSS changes to “Quote” category of posts which I can do on my own.
    – Making Featured Image a Background Image of a post from “Quote” category in a blog/archive view which I can’t do on my own.
    – Making the post from “Quote” category a blog/archive page only with no way to enter single post page which I can’t do on my own.

    2. My current structure of categories looks like that (cars example for simplicity):
    Level 0 (parent of all) – All Vehicles
    Level 1 (children of level 0) – All Vehicles: Cars, Boats, Planes
    Level 2 (children of level 1) – Cars: Off-Road Cars, Sport Cars
    Level 3 (children of level 2) – Off-Road Cars: Jeep, Hummer
    etc.

    Code that I shown in post #1149615 works but what it does is:
    – Adds to an Article under Jeep category, additional class All Vehicles (tested using FireBug inspection),
    And what I need is:
    – Add to an Article under Jeep category, additional classes: Off-Road Cars (parent of Jeep), Cars (parent of Off-Road cars) and All Vehicles (parent of Cars).

    And code that I shown in post #1149180 sadly doesn’t do anything at all (inspection using FireBug shows no added classes to a post) or I’m putting it in the wrong place (functions.php the same place as the other code that works).

    3. I want to avoid custom development completely. I meant did any of Your customers use such completely manual related/recommended posts plugin and left a “it works well with X Theme” feedback? That’s all I’m asking.

    4. This is gonna give me some insight to all those differences between stacks, thanks.

    #1150205
    Rad
    Moderator

    Hi there,

    1. Hmm, looks like it’s big. If it’s just changing the background image then it’s possible with jQuery and CSS. Though, seems like you’re trying to change default functionality and feature of each post format. I could give you some idea,

    The templates responsible on them are located at /wp-content/themes/x/framework/views/{YOUR CURRENT STACK}/

    It’s in a format of content.php and content-{POST_FORMAT}.php. There you can do some coding to change some background or link.

    You can use wp_get_attachment_image_src() ( https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/ ) to get the featured image’s URL and use it as a background. Then use get_post_format() ( https://codex.wordpress.org/Function_Reference/get_post_format ) to get the current post format and add some condition.

    Example,

    if ( get_post_format() !== 'quote' ) {
    echo get_permalink();
    }

    This will display the link on all posts except on quote post format. This is just a sample but you have to apply the same idea on post format templates. I can’t really provide instructions from scratch, it’s a big topic and you may need some help from a developer.

    2. Ah, you need to add all category instead of just the parent. In that case, change this line of code

    $classes[]='category-'.$parent[0];

    to this,

    if( is_array( $parent ) && count( $parent ) > 0 ) {
    
    foreach ( $parent as $cat_slug ) {
    
    $classes[]='category-'.$cat_slug;
    
    }
    
    }

    3. I do see some but I don’t remember what plugin or feature they are using and they could be custom too.

    4. You’re welcome 🙂

    Thanks!

    #1151018
    necxelos
    Participant

    1. I was able to completely strip down posts from single category to just their text using CSS and now it’s thin and clean just like I needed.
    – So for background I need to just make function like: IF post belongs to Quote Category DO set Featured Image as Background Image? Or did I get it wrong?
    – As for disabling single post view for posts from single category I was able to find something like this:

    add_action( 'template_redirect', 'wpse_128636_redirect_post' );
    
    function wpse_128636_redirect_post() {
      $queried_post_type = get_query_var('post_type');
      if ( is_single() && 'my_post_type' ==  $queried_post_type ) {
        wp_redirect( home_url(), 301 );
        exit;
      }
    }

    But it works for custom post types not classic post types of specific category. And honestly I’m not 100% sure what it exactly does…

    I also found this:

    Thought For The Day


    Is that a custom post template in integrity or something? Does it have some separate features?

    2. Works like a charm but there is some strange side-effect too: something that I can only call “fake class” added to all the posts at the end <article>. Here’s code inspected using FireBug:

    <article id="post-127" class="post-127 post type-post status-publish format-standard has-post-thumbnail hentry category-artificial_intelligence-en tag-cpp-en tag-java-en tag-python-en category-all_articles-en category-science-en category-software-en category-">

    3. So far I only found this:
    https://pl.wordpress.org/plugins/baw-manual-related-posts/
    It does exactly what I need it to do but is severely outdated (12 months) with no support topics answered whatsoever (which suggests: dead). You think it’s safe using plugin like this?

    4. I was kind of right, most unique features of stacks other then Ethos are related to layout, styling or presentation in general. Ethos unique features are more functionality focused, allowing some pretty neat and hard/impossible to replicate stuff. I’m now convinced more then ever to switch to Ethos sooner or later (but still before my site goes live).

    Either way I found something that isn’t mentioned in Knowledge base and I wasn’t able to find it in stacks other then Ethos: search menu in main navigation that stretches across whole screen – is this unique to Ethos too or is it available in other stacks?

    #1151116
    Rad
    Moderator

    Hi there,

    1. I see, glad to hear that.

    – You’ll have to add condition when it should set the image as background, and when it’s not.
    – You can change it to this,

    add_action( 'template_redirect', 'wpse_128636_redirect_post' );
    
    function wpse_128636_redirect_post() {
      if ( is_singular('post') ) {
        wp_redirect( home_url(), 301 );
        exit;
      }
    }

    Though, I’m not sure why you need to redirect it if you just wish to disable the linking, what you need is similar to this

    add_filter('post_link', 'do_not_link', 999, 3);
    
    function do_not_link (  $url, $post, $leavename=false ) {
    
    if ( get_post_format() !== 'quote' && !is_admin() ) {
    return '#';
    }
    
    return $url;
    
    }

    I just re-used the condition if ( get_post_format() !== ‘quote’ ) from my previous sample.

    This one http://demo.theme.co/integrity-1/thought-for-the-day/ is default to integrity, and it uses quote post format template.

    2. You mean this category- ? We can improve it to something like this

    if( is_array( $parent ) && count( $parent ) > 0 ) {
    
    foreach ( $parent as $cat_slug ) {
    
    if ( !empty( $cat_slug ) ) $classes[]='category-'.$cat_slug;
    
    }
    
    }

    3. As long as it doesn’t break your site then it should be okay. But, if you wish to make it sure then you can test it on your cloned site. I do that as habit 🙂

    4. Is it the search popup window? It’s available on all stacks and can be turned on on Header section of your customizer. Or maybe I didn’t understand it, would you mind providing a screenshot?

    Thanks!

    #1151976
    necxelos
    Participant

    1.
    BACKGROUND PART. About that code:

    if ( get_post_format() !== 'quote' ) {
    echo get_permalink();
    }

    – I’ve got no idea what to do with this snippet, sadly. There is only one line of code in content.php that relates to featured image which is <?php x_featured_image(); ?> and there is nothing about the background there.

    SINGLE POST VIEW DISABLING PART. First code didn’t do what I think it did after all. It looks like it loads the homepage (in this case blog page) again when You click the link.

    What I thought, is that it disables single-post view whatsoever. So that the single-post URL doesn’t exist in the first place and the post is only there in blog/archive pages.

    Second code on the other hand is the one very close to what I need. It doesn’t load homepage again, it just makes You stay on the same page You were (whatever that page was), which is awesome.
    BUT:
    – It “jumps” the view to the top of the page. Is it possible for the view to stay were it was too (so visually nothing happens)?
    – I can still manually enter single post page using an URL. Is it possible to get rid of that too?
    – How do I limit this code to work only for posts from one category? Because just writing my category in place of ‘quote’ in the code does nothing, it still works for all the categories…

    2. Yes category- was the one. And it looks like change You proposed got rid of it 🙂

    3. You mean if it “works” (and it does for now) I can safely assume it will carry on doing so?

    4. Yes, this is the one. And it works, thanks 🙂

    #1152874
    Rad
    Moderator

    Hi there,

    1. Yes, it’s just a sample. About the X’s featured image code, this is the code responsible for that

    function x_featured_image( $cropped = '' ) {
    
        $stack     = x_get_stack();
        $fullwidth = ( in_array( 'x-full-width-active', get_body_class() ) ) ? true : false;
    
        if ( has_post_thumbnail() ) {
    
          if ( $cropped == 'cropped' ) {
            if ( $fullwidth ) {
              $thumb = get_the_post_thumbnail( NULL, 'entry-cropped-fullwidth', NULL );
            } else {
              $thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL );
            }
          } else {
            if ( $fullwidth ) {
              $thumb = get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );
            } else {
              $thumb = get_the_post_thumbnail( NULL, 'entry', NULL );
            }
          }
    
          switch ( is_singular() ) {
            case true:
              printf( '<div class="entry-thumb">%s</div>', $thumb );
              break;
            case false:
              printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
                esc_url( get_permalink() ),
                esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
                $thumb
              );
              break;
          }
    
        }
    
      }

    You can place this code to your child theme’s functions.php and apply your customization

    About the code I provided, it jumps because the links is #, you can change it to javascript:void(0);

    Example,

    if ( get_post_format() !== 'quote' && !is_admin() ) {
    return 'javascript:void(0)';
    }

    And if you don’t wish your user to go directly to a single post, then that’s when you apply the redirect. Hence, it will be a combination of discussed codes. And about your question that apply it to specific category, then you can do something like this

    
    $post_categories = wp_get_post_categories();
    $target_categories = array( 834, 2312, 9823);
    
    if ( ( get_post_format() !== 'quote' || in_array( $target_categories, $post_categories ) ) && !is_admin() ) {
    return 'javascript:void(0)';
    }

    $target_categories contains the IDs of your target categories.

    3. Yes, you can continue what you’re doing.

    Glad that other issues are now resolved 🙂 Thanks!

    #1153635
    necxelos
    Participant

    1. SINGLE POST VIEW DISABLING PART:
    Either I misunderstood something or it doesnt work for me.
    – Both code versions of:

    add_filter('post_link', 'do_not_link', 999, 3);
    function do_not_link (  $url, $post, $leavename=false ) {
    if ( get_post_format() !== 'quote' && !is_admin() ) {
    return '#'; // This one or the one with 'javascript:void(0)' instead
    }
    return $url;
    }

    …work exactly the same way (they do move viewpoint to the top of a page).
    – And the code:

    $post_categories = wp_get_post_categories();
    $target_categories = array( 17);
    if ( ( get_post_format() !== 'quote' || in_array( $target_categories, $post_categories ) ) && !is_admin() ) {
    return 'javascript:void(0)';
    }

    …does it’s job on every post, not just the one from category 17 (this is my actual category ID of a standard post).

    1. BACKGROUND IMAGE PART:
    Using information from You as searchpoint I was able to find and apply something like this:

    // This goes at the top.
    PHP:
    <?php $background = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'full' ); ?>
    // This goes inside.
    HTML:
    <div class="entry-wrap" style="background-image: url('<?php echo $background[0]; ?>');">

    …to my content.php file.
    BUT
    – This code resides in content.php and I need conditional (only for one category) so I’d prefer code that resides in functions.php.
    – This code uses some crazy-size version of featured image AND it overflows the image in crazy places (piece of image from a post, sometimes lands between posts “few posts below”.

    #1154332
    Lely
    Moderator

    Hi There,

    1.)SINGLE POST VIEW DISABLING PART:
    Because of this part ||. That means logical operator OR. If the port format is not a quote, which on your case will probably true, OR it is in category 17 and is not admin. It will always go through because the first part of the condition is true. Please update to this:

    $post_categories = wp_get_post_categories();
    $target_categories = array( 17);
    if ( ( get_post_format() !== 'quote' && in_array( $target_categories, $post_categories ) ) && !is_admin() ) {
    return 'javascript:void(0)';
    }

    2.) To filter that in Category, you may just update that code to this:

    <?php 
    if(is_category(17)){
    $background = wp_get_attachment_image_src( get_post_thumbnail_id( $page->ID ), 'full' ); 
    } ?>
    
    <div class="entry-wrap" style="background-image: url('<?php echo $background[0]; ?>');">
    
    

    Change 17 to your own category ID.

    Hope this helps.

    #1154422
    necxelos
    Participant

    BACKGROUND: Code that sends featured image URL to background URL works but the conditional part if is_category() {} isn’t working.

    Judging by the function description I think it’s due to the fact that function checks if the page I’m in belongs to that certain category (instead of checking if the post belongs to that certain category).

    I tested the conditional and it works only when I enter the category archive of a specified category, which makes it kind of pointless, because the whole reason was to differentiate one specific post category from others, in a situation where posts from multiple categories are on the same page (AKA: blog page and category archive page, the latter making sense because there are child categories of an archive involved).

    SINGLE POST VIEW DISABLING PART: I put this code in my functions.php and nothing happens. And I’m 100% sure I’m using right category ID (17), I checked it in backend category URL and the same category ID was recognized in background code.

  • <script> jQuery(function($){ $("#no-reply-1146799 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>