0

I made my first wordpress child theme, but it's not working correctly. This is my custom-functions.php coding:

// custom excerpt length
function themify_custom_excerpt_length( $length ) {
   return 20;
}
add_filter( 'excerpt_length', 'themify_custom_excerpt_length', 999 );

//show logged-in menu and logged out menu
function my_wp_nav_menu_args( $args = ” ) {
if ($args[‘theme_location’] == ‘primary’) {
if( is_user_logged_in()) {
$args[‘menu’] = ‘logged-in’;
}else{
$args[‘menu’] = ‘logged-out’;
}
}
return $args;
}
add_filter( ‘wp_nav_menu_args’, ‘my_wp_nav_menu_args’ );


//Post database text on each post page within the loop
add_filter( 'the_content', 'my_the_content_filter', 20 );

function my_the_content_filter( $content ) {
    if ( is_single() ){
    $newcontent="here will be some data retrieved from the database, it will be beneath every post. I like it!";        
    $content .= $newcontent;
    return $content;}
}

Problem is that my excerpts don't show up on the main page. I think this is related to the return $content part in my last function. If I remove my child theme the excerpts do show up, so there must be something wrong with my coding.

Anyone got a clue on how to get this working?

0

This should output the text at the bottom of each 'single' post

add_filter( 'the_content', 'my_the_content_filter', 0 );
function my_the_content_filter( $content ) {
  if ( is_single() )
    {
      global $post;      
      $content .= "<p>here will be some data retrieved from the database, it will be beneath every post. I like it!</p>";    
    }
  return $content;
}

you could use is_front_page() or is_home() if you wanted the content on the home page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.