- This topic has 14 replies, 2 voices, and was last updated 8 years, 9 months ago by calmo16.
-
AuthorPosts
-
February 17, 2016 at 5:29 am #85607calmo16Participant
Hi,
I want to get rid of the text ‘permalink to: ….’ while hovering featured content. Can I do it with CSS?
Thanks in advance.
BR Calmo16February 17, 2016 at 10:35 am #85621MaheshParticipantHi calmo16,
You need to create a child theme for this. You can find more on creating child theme HERE. Then in your child theme’s functions.php add the following code:
function catchbox_sliders() { global $post; //delete_transient( 'catchbox_sliders' ); // get data value from catchbox_options_slider through theme options $options = catchbox_get_theme_options(); // get slider_qty from theme options if( !isset( $options['slider_qty'] ) || !is_numeric( $options['slider_qty'] ) ) { $options[ 'slider_qty' ] = 4; } $postperpage = $options[ 'slider_qty' ]; //In customizer, all values are returned but with empty, this rectifies the issue in customizer if( isset( $options[ 'featured_slider' ] ) && !array_filter( $options[ 'featured_slider' ] ) ) { return; } if( ( !$catchbox_sliders = get_transient( 'catchbox_sliders' ) ) && !empty( $options[ 'featured_slider' ] ) ) { echo '<!-- refreshing cache -->'; $catchbox_sliders = ' <div id="slider"> <section id="slider-wrap">'; $get_featured_posts = new WP_Query( array( 'posts_per_page' => $postperpage, 'post__in' => $options[ 'featured_slider' ], 'orderby' => 'post__in', 'ignore_sticky_posts' => 1 // ignore sticky posts )); $i=0; while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++; $title_attribute = esc_attr( apply_filters( 'the_title', get_the_title( $post->ID ) ) ); if ( $i == 1 ) { $classes = "slides displayblock"; } else { $classes = "slides displaynone"; } $catchbox_sliders .= ' <div class="'.$classes.'"> <a href="'. esc_url ( get_permalink() ).'" title="'.sprintf( esc_attr__( '%s', 'catch-box' ), the_title_attribute( 'echo=0' ) ).'" rel="bookmark"> '.get_the_post_thumbnail( $post->ID, 'featured-slider', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class' => 'pngfix' ) ).' </a> <div class="featured-text">' .the_title( '<span class="slider-title">','</span>', false ).' <span class="sep">:</span> <span class="slider-excerpt">'.get_the_excerpt().'</span> </div><!-- .featured-text --> </div> <!-- .slides -->'; endwhile; wp_reset_query(); $catchbox_sliders .= ' </section> <!-- .slider-wrap --> <nav id="nav-slider"> <div class="nav-previous"><img class="pngfix" src="'.get_template_directory_uri().'/images/previous.png" alt="next slide"></div> <div class="nav-next"><img class="pngfix" src="'.get_template_directory_uri().'/images/next.png" alt="next slide"></div> </nav> </div> <!-- #featured-slider -->'; set_transient( 'catchbox_sliders', $catchbox_sliders, 86940 ); } echo $catchbox_sliders; }
Regards,
MaheshFebruary 17, 2016 at 2:55 pm #85633calmo16ParticipantHi Mahesh,
I’ve added the code in my functions.php, but nothing has changed.
PS: I didn’t create a Child Theme so far, but the code should work in the original functions.php as well, I think?
BR Calmo16
February 17, 2016 at 4:15 pm #85643MaheshParticipantHi calmo16,
The above code was for Catch Box. Please replace it with the following for Clean Box.
function clean_box_page_slider( $options ) { $quantity = $options['featured_slider_number']; $more_link_text = $options['excerpt_more_text']; global $post; $clean_box_page_slider = ''; $number_of_page = 0; // for number of pages $page_list = array(); // list of valid page ids //Get number of valid pages for( $i = 1; $i <= $quantity; $i++ ){ if( isset ( $options['featured_slider_page_' . $i] ) && $options['featured_slider_page_' . $i] > 0 ){ $number_of_page++; $page_list = array_merge( $page_list, array( $options['featured_slider_page_' . $i] ) ); } } if ( !empty( $page_list ) && $number_of_page > 0 ) { $get_featured_posts = new WP_Query( array( 'posts_per_page' => $quantity, 'post_type' => 'page', 'post__in' => $page_list, 'orderby' => 'post__in' )); $i=0; while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++; $title_attribute = the_title_attribute( array( 'echo' => false ) ); $excerpt = get_the_excerpt(); if ( $i == 1 ) { $classes = 'page pageid-'.$post->ID.' hentry slides displayblock'; } else { $classes = 'page pageid-'.$post->ID.' hentry slides displaynone'; } $clean_box_page_slider .= ' <article class="'.$classes.'"> <figure class="slider-image">'; if ( has_post_thumbnail() ) { $clean_box_page_slider .= '<a title="' . esc_attr( $title_attribute ) . '" href="' . get_permalink() . '"> '. get_the_post_thumbnail( $post->ID, 'clean-box-slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ).' </a>'; } else { //Default value if there is no first image $clean_box_image = '<img class="pngfix wp-post-image" src="'.get_template_directory_uri().'/images/gallery/no-featured-image-1680x720.jpg" >'; //Get the first image in page, returns false if there is no image $clean_box_first_image = clean_box_get_first_image( $post->ID, 'fullframe-slider', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ); //Set value of image as first image if there is an image present in the page if ( '' != $clean_box_first_image ) { $clean_box_image = $clean_box_first_image; } $clean_box_page_slider .= '<a title="' . esc_attr( $title_attribute ) . '" href="' . get_permalink() . '"> '. $clean_box_image .' </a>'; } $clean_box_page_slider .= ' </figure><!-- .slider-image --> <div class="entry-container"> <header class="entry-header"> <h1 class="entry-title"> <a title="' . esc_attr( $title_attribute ) . '" href="' . get_permalink() . '">'.the_title( '<span>','</span>', false ).'</a> </h1> <div class="assistive-text">'.clean_box_page_post_meta().'</div> </header>'; if( $excerpt !='') { $clean_box_page_slider .= '<div class="entry-content">'. $excerpt.'</div>'; } $clean_box_page_slider .= ' </div><!-- .entry-container --> </article><!-- .slides -->'; endwhile; wp_reset_query(); } return $clean_box_page_slider; }
Note: Please use child theme. If you change the core files, all your change will be lost after theme update.
If you don’t see any changes (may be because of transient), please go to customize and save change something and it will work fine.
Let me know if any problems.Regards,
MaheshFebruary 17, 2016 at 4:28 pm #85645calmo16ParticipantHi Mahesh,
I doesn’t work.
What do you mean by ‘save change something’?
I’ve changed several options in Customizer.BR calmo16
February 17, 2016 at 4:40 pm #85646MaheshParticipantHi @calmo16,
The settings are set in the transient such as cache for performance enhancement, so changing some setting(anything e.g. change color) in customizer will clear the transient. If you are still seeing the “Permalink to”, it must be because of transient. Please let me know if any problem.
Regards,
MaheshFebruary 17, 2016 at 5:27 pm #85650calmo16ParticipantI’ve done the process again, but still no changes…
After clearing cache still no changes…February 18, 2016 at 9:12 am #85690MaheshParticipantHi @calmo16,
I assume you have created child theme and done all the changes I’ve mentioned above. Seems you are still using the parent theme. Please activate the child theme for changes.
Let me know if any issue.Regards,
MaheshFebruary 18, 2016 at 3:10 pm #85713calmo16ParticipantHi Mahesh,
I will use the child theme after i have tested some things.
Could it be the code is not good? – i’m not using a slider but content – as you see.
Well I really don’t know why it doesn’t work.BR calmo16
February 18, 2016 at 3:42 pm #85716MaheshParticipantHi @calmo16,
Sorry, I thought it to be Featured Slider. The above code is for Featured Slider, for Featured Content, add the code below in child theme’s
functions.php
function clean_box_page_content( $options ) { global $post; $quantity = $options [ 'featured_content_number' ]; $more_link_text = $options['excerpt_more_text']; $show_content = isset( $options['featured_content_show'] ) ? $options['featured_content_show'] : 'excerpt'; $clean_box_page_content = ''; $number_of_page = 0; // for number of pages $page_list = array(); // list of valid pages ids //Get valid pages for( $i = 1; $i <= $quantity; $i++ ){ if( isset ( $options['featured_content_page_' . $i] ) && $options['featured_content_page_' . $i] > 0 ){ $number_of_page++; $page_list = array_merge( $page_list, array( $options['featured_content_page_' . $i] ) ); } } if ( !empty( $page_list ) && $number_of_page > 0 ) { $get_featured_posts = new WP_Query( array( 'posts_per_page' => $number_of_page, 'post__in' => $page_list, 'orderby' => 'post__in', 'post_type' => 'page', )); $i=0; while ( $get_featured_posts->have_posts()) : $get_featured_posts->the_post(); $i++; $title_attribute = the_title_attribute( array( 'echo' => false ) ); $excerpt = get_the_excerpt(); $clean_box_page_content .= ' <article id="featured-post-' . $i . '" class="post hentry featured-page-content">'; if ( has_post_thumbnail() ) { $clean_box_page_content .= ' <figure class="featured-homepage-image"> <a href="' . get_permalink() . '" title="' . $title_attribute . '"> '. get_the_post_thumbnail( $post->ID, 'medium', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ) .' </a> </figure>'; } else { $clean_box_first_image = clean_box_get_first_image( $post->ID, 'medium', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ); if ( '' != $clean_box_first_image ) { $clean_box_page_content .= ' <figure class="featured-homepage-image"> <a href="' . get_permalink() . '" title="' . $title_attribute . '"> '. $clean_box_first_image .' </a> </figure>'; } } $clean_box_page_content .= ' <div class="entry-container"> <header class="entry-header"> <h1 class="entry-title"> <a href="' . get_permalink() . '" rel="bookmark">' . the_title( '','', false ) . '</a> </h1> </header>'; if ( 'excerpt' == $show_content ) { $clean_box_page_content .= '<div class="entry-excerpt"><p>' . $excerpt . '</p></div><!-- .entry-excerpt -->'; } elseif ( 'full-content' == $show_content ) { $content = apply_filters( 'the_content', get_the_content() ); $content = str_replace( ']]>', ']]>', $content ); $clean_box_page_content .= '<div class="entry-content">' . $content . '</div><!-- .entry-content -->'; } $clean_box_page_content .= ' </div><!-- .entry-container --> </article><!-- .featured-post-'. $i .' -->'; endwhile; wp_reset_query(); } return $clean_box_page_content; }
Regards,
MaheshFebruary 18, 2016 at 3:58 pm #85719calmo16ParticipantOK
Well so far the Featured Content, but what about the Featured Grid Content? 🙂
BR calmo16February 18, 2016 at 4:11 pm #85721MaheshParticipantHi @calmo16,
You’ll need to override another function that displays Featured Grid Content similarly as for Featured Slider and Featured Content. Add the following code in you child theme’s
functions.php
function clean_box_page_grid_content( $options ) { $quantity = $options['featured_grid_content_number']; global $post; $clean_box_page_grid_content = ''; $number_of_page = 0; // for number of pages $page_list = array(); // list of valid page ids //Get number of valid pages for( $i = 1; $i <= $quantity; $i++ ){ if( isset ( $options['featured_grid_content_page_' . $i] ) && $options['featured_grid_content_page_' . $i] > 0 ){ $number_of_page++; $page_list = array_merge( $page_list, array( $options['featured_grid_content_page_' . $i] ) ); } } if ( !empty( $page_list ) && $number_of_page > 0 ) { $get_featured_posts = new WP_Query( array( 'posts_per_page' => $quantity, 'post_type' => 'page', 'post__in' => $page_list, 'orderby' => 'post__in' )); $i=1; while ( $get_featured_posts->have_posts() ) { $get_featured_posts->the_post(); $title_attribute = the_title_attribute( array( 'echo' => false ) ); $classes = 'page pageid-' . $post->ID; if ( 1 == $i ) { $classes .= ' first'; } else if ( 1 == $i%3 ) { $classes .= ' first-cols'; } $clean_box_page_grid_content .= '<a class="grid-box '. $classes .'" title="' . $title_attribute . '" href="' . get_permalink() . '">'; if ( has_post_thumbnail() ) { if ( 1 == $i ) { $clean_box_page_grid_content .= get_the_post_thumbnail( $post->ID, 'clean-box-featured-grid', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ); } else{ $clean_box_page_grid_content .= get_the_post_thumbnail( $post->ID, 'clean-box-featured-content', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ); } } else { //Default value if there is no first image $clean_box_image = '<img class="no-image pngfix" src="'.get_template_directory_uri().'/images/gallery/no-featured-image-800x450.jpg" />'; //Get the first image in page, returns false if there is no image $clean_box_first_image = clean_box_get_first_image( $post->ID, 'medium', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) ); //Set value of image as first image if there is an image present in the post if ( '' != $clean_box_first_image ) { $clean_box_image = $clean_box_first_image; } $clean_box_page_grid_content .= $clean_box_image; } $clean_box_page_grid_content .= ' <div class="caption"> <span class="vcenter"> <span class="entry-title"> ' . the_title('', '', false) . ' </span> <span class="more">'; $clean_box_page_grid_content .= $options['excerpt_more_text']; $clean_box_page_grid_content .= ' </span><!-- .more --> </span><!-- .vcenter --> </div><!-- .caption --> </a><!-- .grid-box -->'; $i++; } wp_reset_query(); } return $clean_box_page_grid_content; }
Regards,
MaheshFebruary 18, 2016 at 4:29 pm #85722calmo16ParticipantNope, now the Feature Grid Content is ok, but the Feature Content isn’t 🙁
February 18, 2016 at 4:54 pm #85727MaheshParticipantHi @calmo16,
The above code is working fine on our server(local). It should work fine. May be some transient(cache) problem.
Regards,
MaheshFebruary 18, 2016 at 5:20 pm #85732calmo16ParticipantOops, cache.
It works!
Thanks a lot, Mahesh. -
AuthorPosts
- The topic ‘How to delete 'permalink to: + text' from featured content’ is closed to new replies.