Change Featured Pages Title and Links.
-
I need to change the Featured Page Title and Links for my website but I can’t figure out a few things. I found these snippets on the themesandco website but I cant figure out what part of the code I should change to get what I want. If this were CSS I would just copy and paste to see what i get, but this is PHP, I’m kinda afraid of php because last time I made an error on one code and my whole site crashed. Got an error message every time i tried to log in or see my site. Don’t want to risk making another mistake again.
These are the codes I need to add to my PHP file but I’m unsure what part I should change.
To change the titles, this is the code I need to put in my PHP, but I don’t know what part of it to modify.
add_filter('tc_fp_title' , 'my_custom_fp_titles', 10 ,3); function my_custom_fp_titles( $original_title , $fp_id = null , $page_id = null ) { //assigns a custom title by page id $custom_title = array( //page id => 'Custom title' 2 => 'My custom title', 9 => 'Title Example for page id #9' ); //if no custom title is defined for the current page id, return original if ( ! isset($custom_title[$page_id]) ) return $original_title; return $custom_title[$page_id]; }
To change the links, this is the code I need to add. What part do I modify? Also where can I add the target=”_blank” to open in a new window?
add_filter('tc_fp_link_url' , 'my_custom_fp_links', 10 ,2); function my_custom_fp_links( $original_link , $fp_id ) { //assigns a custom link by page id $custom_link = array( //page id => 'Custom link' 2 => 'https://www.my-custom-url-one.com', 9 => 'https://www.my-custom-url-two.com' ); foreach ($custom_link as $page_id => $link) { if ( get_permalink($page_id) == $original_link ) return $link; } //if no custom title is defined for the current page id, return original return $original_link; }
If you can answer my question I’d greatly appreciate it! Also please be as specific as possible. Thanks in advance.
- The topic ‘Change Featured Pages Title and Links.’ is closed to new replies.