How to supress excerpt on these archive pages

  • On these automatically generated pags (archive?) I need to supress the output of the excrpt. How cam I realise it? How to attach the needed CSS?

    Example

  • Hi there,

    Go to Customize > Layout > Blog, then under Content > Archives, set the Excerpt word count to 0 (or clear the value).

  • I know it. I want to give the archives of CPT ‘mitglieder’ another layout.

    This is what I want to achieve:

    Layout

    In addition I want to sort the posts by a meta term.

    Probably I have to write some php code. But where must it placed???

    By the way – the items should be sorted by meta ‘sortier-name’.

  • I generated an example page which shows what I want to achieve.

    HFA

    And this is the code.

    
    add_shortcode( 'HFA', function ($atts) {
    /*
    	SPD Mitglieder Haupt- und Finanzausschuss
    */
    	global $wpdb;
    	$titel = 'Haupt- und Finanzausschuss';
        $out = '';
        $args = array(
    		'post_type' => 'mitglieder',
       		'tax_query' => array(
           		 array(
            	'taxonomy' => 'ausschuss',
           		'field' => 'slug',
            	'terms' => 'a-haupt')),
    		'post_status' => 'publish',
    	    'posts_per_page' => -1,
            'order' => 'ASC',
            'orderby'   => 'order_clause',   
            'meta_query' => array(
            'order_clause' => array(
            'key' => 'sortiername'
        )));
      $liste = get_posts($args);
      if ($liste) {
    		$out .= "<div class='pf-p-flex-container'>";
    		foreach ($liste as $satzk) {
    			$out .= '<div class="pf-p-flex-item">';
    			$out .= '<div class="pf-avatar">';
    			$out .= '<a href="https://spd-simmerath.de/mitglieder/' . $satzk->post_name . '">';
    			$out .= '<div>' . get_the_post_thumbnail( $satzk->ID, 'full') . '</div>';
            	$out .= '</a>';
    			$out .= '</div>';
    			$out .= '<a href="https://spd-simmerath.de/mitglieder/' . $satzk->post_name . '">';
    			$out .= '<span class="sw-butt">' . $satzk->post_title . '</span></a>';
    		    $out .= '</div>';
    		}
    	  	$out .= '</div>';
    	}
    return $out;
    }
    );
    

    My goal is to generate all these numerous pages automatically by an addition to the archive.php. Could you please advice me where to integrate the neede code. Also the terms change very often so no handy work would be needed except one click in the defnition of the CPT ‘mitglieder’.

  • Try adding the shortcode to a block element – loop template, and assign it to your archives.

  • Could you please be more precice about your advice.

  • The code you shared is to generate a shortcode HFA, then you can add this shortcode [HFA] to a block element – loop template, and set the location to the archive.

    Let me know if this works!

  • I believe the solution with a shortcode will not work. I change it to a function with two parameters:first parameter: taxonomy, second paramter: term. This is needed as the CPT has 7 taxonomies with up to numerous terms.

    I intend to integrate this function into the archive.php placed in a
    child theme.

    Unfortunately I do not know where the code for such a function must be inserted.

    Do you think that this is a fitting approach? Could you please advice me where to insert the code in the archive.php?

  • I believe the solution with a shortcode will not work.

    Have you tried it? It looks quite promising to me.

  • I followed your advice and built a shortcode with two parameters.

    Aufruf

    This is the code:


    function mitglieder_term($atts = array) {
    /* $werte = shortcode_atts( array(
    ‘tax_s’ => ”,
    ‘term_s’ => ”,
    ), $atts );*/
    $tax = $atts[‘tax_s’];
    $term = $atts[‘term_s’];
    /*
    SPD Mitglieder Term
    */
    global $wpdb;
    $tax = $werte->tax_s;
    $term = $werte->term_s;
    echo $tax .’ – ‘ . $term;
    $terma = get_term_by(‘slug’, $term, $tax );
    $titel = $terma->name;
    echo $title;
    $out = ”;
    $args = array(
    ‘post_type’ => ‘mitglieder’,
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => $tax,
    ‘field’ => ‘slug’,
    ‘terms’ => $term)),
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => -1,
    ‘order’ => ‘ASC’,
    ‘orderby’ => ‘order_clause’,
    ‘meta_query’ => array(
    ‘order_clause’ => array(
    ‘key’ => ‘sortiername’
    )));
    $liste = get_posts($args);
    if ($liste) {
    $out .= “<div class=’pf-p-flex-container’>”;
    foreach ($liste as $satzk) {
    $out .= ‘<div class=”pf-p-flex-item”>’;
    $out .= ‘<div class=”pf-avatar”>’;
    $out .= ‘post_name . ‘”>’;
    $out .= ‘<div>’ . get_the_post_thumbnail( $satzk->ID, ‘full’) . ‘</div>’;
    $out .= ‘
    ‘;
    $out .= ‘</div>’;
    $out .= ‘post_name . ‘”>’;
    $out .= ‘<span class=”sw-butt”>’ . $satzk->post_title . ‘</span>
    ‘;
    $out .= ‘</div>’;
    }
    $out .= ‘</div>’;
    }
    return $out;
    };
    add_shortcode(‘mitglieder_term’,’mitglieder_term’);
    `

    And this is the result.

    Output

    The shortcode is activated!

    I cannot find an error. Do you find it?

  • Your image isn’t showing. Can you check the image link?

  • I just inserted it. The upper layout is created by WP Show Posts which I want to supstitude due to hundrets warnings.
    Then comes the shortcode which is the reason for this request.
    The last picture is created by a loop with system output with a layout which I don’t like.

  • The layout you’re trying to achieve is simple to build in the block editor—no complex shortcode needed. Can you provide your site login so I can create an example layout for you?

    As for sorting posts by a meta term, that will require a custom snippet, which we can set up once the initial loop layout is created.

  • Thanks for your proposal.

    I already changed the pages where I wanted to replace the WP Show Posts to dynamic data. See private information.

    It would be great if the layout would be like this:

    Layout

    There are also some automatically generated pages where I would like to have the some layout see examplepage 2.

  • I tried to log in to your site, but I received this error: https://cln.sh/y4JrsTRNFb2FyHLrxwDx

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