Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #777127

    Dear Enfold Support Team

    In the portfolio details I need to display the categories. I have added this function to my child theme:

    function show_portfolio_category_func() {
    global $post;
    $the_terms = get_the_terms( $post->ID , ‘portfolio_entries’);
    ob_start();
    echo $the_terms[0]->name;
    $output = ob_get_clean();
    return $output;
    }
    add_shortcode(‘portfolio_category’, ‘show_portfolio_category_func’);

    But I need each selected category (not just one). How can I achieve this?

    Kind regards
    Jeannette

    #777130

    hm first of all – you have looked to the options of portfolio advanced layout element (masonry or grid) ?

    Which categories should be used for the portfolio?
    You can select multiple categories here. The Page will then show posts from only those categories.

    see link with image above. : https://webers-testseite.de/kokon/portfolio/portfolio-3-columns-centered/
    you can activate one by another if you are clicking on the category you like to show under pressing the shift key there is the possibility to choose more than one!

    • This reply was modified 6 years, 11 months ago by Guenni007.
    #777136

    oh i think we can go on to speak now german:
    auf meiner linkseite oben siehst du ja oberhalb des Portfolio Grids die Sortieroptionen musst nur dran denken das auch anzuwählen!

    Sortierung?
    Sollen die Sortierungs-Optionen (auf Kategorien basierend) angezeigt werden?

    und die Categorien kann man oben durch gedrückt halten der Maustaste und ziehen alle anwählen oder eben durch shift (hochstelltaste) halten und einzelklicks.

    #777156

    @Guenni007
    Herzlichen Dank für Deine Antwort. Aber das ist nicht das Problem, welches ich habe. Ich möchte auf der Detail-Seite eines einzelnen Portfolio-Beitrages die Kategorien im Text anzeigen. Ich habe es geschafft, via Shortcode eine einzelne Kategorie anzuzeigen. Ich möchte aber alle ausgewählten Kategorien des einzelnen Portfolio-Beitrages in einem Text-Element anzeigen, ohne dass der Kunde diese nochmals von Hand eingeben muss. Ich würde also eine php Funktion für mein Child Theme benötigen, welche ich wieder als Shortcode einfügen könnte.

    Here in english for the enfold support team:
    I would like to display the categories in the text on the detail page of a single portfolio contribution. I have managed to display a single category via Shortcode. However, I would like to display all the selected categories of the individual portfolio contribution in a text element without the customer having to enter this again manually. So I would need a php function for my child theme, which I could again paste as shortcode.

    #777189

    Weil auf deiner Seite sah ich keine solche Sortieroption – daher das Missverständnis.

    Du willst in einem Portfoliobeitrag irgendwo die Zugehörigkeit zu der Kategorie anzeigen; wobei es Portfolios gibt, die mehreren Kategorien angehören (also du hast ein Foto, welches sowohl Landschaft als auch Architekur z.B ist)

    #777200

    Ja genau, ein Beitrag kann mehreren Kategorien angehören und dies würde ich gerne ausgeben. Und es geht auch gar nicht um meine Seite, sondern um eine für einen Kunden, welche noch gar nicht online ist.

    #777217

    letztendlich hat das ja WordPress schon vorgemacht. In der Beitragsliste stehen ja hinten tabellarisch die Kategorie-Zugehörigkeiten.
    Man sollte denke ich also diese Feld in WordPress finden, und mit in das single.php einbauen können.

    #777265

    ich glaube das einfachste wird sein, man nimmt die beiden loop Dateien:

    loop-index.php und loop-portfolio-single.php sich vor. Da unten werden ja auch schon die tags hin und wieder gelistet!
    mit echo get_the_category_list( ) sollte man das hinbekommen

    Für Beiträge habe ich sowas vorhin schon gezimmert. Ist aber noch nicht optimal: https://webers-testseite.de/kokon/entry-with-post-format-video/

    Abends erst mehr; jetzt muss ich Kundensachen wegbringen.

    • This reply was modified 6 years, 11 months ago by Guenni007.
    #778168

    on elegant blog template there is an output of the concerning categories :

    if(!empty($cats))
    {
        $cat_output .= '<span class="blog-categories minor-meta">';
        $cat_output .= $cats;
        $cat_output .= '</span>';
        $cats = "";
    }

    but that works only if posts were made without advanced layout builder.
    and on portfolio i think these “categories” aren’t categories they have the taxonomie : portfolio-entries
    so first we had to clear how the loop comes to those posts and portfolios made with alb.

    #778610

    Hi,

    also check out this thread: https://kriesi.at/support/topic/category-display-under-portfolio-post-titles/#post-135474
    and if it doesn’t work, I would go for a plugin with such a function, maybe this one could work for you: https://de.wordpress.org/plugins/custom-post-type-ui/

    Thanks @Guenni007 for your input!

    Best regards,
    Andy

    #780007

    Hi Andy
    Hallo Guenni007

    Thanks so much for your help. I have now managed to get my categories with this code, I have added in my child theme functions.php:

    function show_portfolio_category_func() {
    global $post;
    $sort_classes = “”;
    $item_categories = get_the_terms( $post->ID , ‘portfolio_entries’ );
    ob_start();
    if(is_object($item_categories) || is_array($item_categories))
    {
    foreach ($item_categories as $cat)
    {
    $sort_classes .= $cat->name.’, ‘;
    }
    }
    echo $sort_classes .= $cat->name;
    $output = ob_get_clean();
    return $output;
    }
    add_shortcode(‘portfolio_category’, ‘show_portfolio_category_func’);

    But I have the problem that it shows the last category in double (example : Geländer, Treppen, Treppen). How do I fix this?

    #780195

    please prove your code above. If i put it in my functions.php i got white paper view

    #780687

    I have changed my code to this:

    function show_portfolio_category_func() {
    global $post;
    ob_start();
    $sort_classes = “”;
    $item_categories = get_the_terms( $post->ID , ‘portfolio_entries’ );
    if(is_object($item_categories) || is_array($item_categories))
    {
    foreach ($item_categories as $cat)
    {
    $sort_classes .= $cat->name.'<span class=”cat-komma”>, </span>’;
    }
    }
    echo $sort_classes;
    $output = ob_get_clean();
    return $output;
    }
    add_shortcode(‘portfolio_category’, ‘show_portfolio_category_func’);

    This works for me, no double entries. I had just an extra comma at the end of the list, which I did not display with this css code:
    .avia_textblock .cat-komma:last-child {
    display:none;
    }
    Sorry, no PHP programmer. Just know some HTML & CSS :-)

    Kind regards
    Jeannette

    #781187

    Hi,

    glad it’s working fine for you now!
    Please feel free to open a new ticket if you have any other questions or issues related to our themes. We’re happy to assist you.

    Best regards,
    Andy

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.