Language: php

111 posts

Restrict the post navigation to the same category

WordPress offers built-in functions to display the previous and next post link.   next_post_link( $format, $link, $in_same_term = false, $excluded_terms = ”, $taxonomy = ‘category’ ); previous_post_link( $format, $link, $in_same_term = false, $excluded_terms = ”, $taxonomy = ‘category’ ); As you can see there’s a boolean parameter named ‘in_same_term’. This […]

Display a slider in the 404 and search pages

Let’s say you have created a slider named “my-slider” and you want to display it in your 404 page or in your search pages. Since there’s no option to style those pages from the WP admin, you’ll have to code something. Here’s a short snippet to do it. add_filter(‘tc_show_slider’ , […]

customizr-featured-pages

Apply custom or random images to the featured pages

By default in the Customizr theme, the featured pages images use by priority : the page featured images if the featured image is not set, then it uses the first image (ordered by date) attached to this page. (in other words, the first images that has been inserted in the WYSIWYG […]

Removing the title links in post lists

The Customizr theme displays by default your post titles as links pointing to the single post. Here’s a simple way (using some javascript) to remove those links if you ever need to. Paste the following code in your functions.php : add_action(‘wp_head’ , ‘remove_post_list_title_links’); function remove_post_list_title_links() { ?> <script id=”remove-links-in-title” type=”text/javascript”> […]

Featuring pages on another page / post than home

Let’s say you’ve setup three beautiful featured pages on your home page. Now you might want to display this block of featured pages in another post or page of your website. This snippet will show you how to do it.   Note : Customizr-Pro and Featured Pages Unlimited users should replace `__get_option` with […]

Add a specific page or post content in another post or page

Following this discussion in the Customizr theme support forum, here’s a simple piece of code that will allow you to add any post or page before your post or page content in the Customizr WordPress theme. The following snippet will add the content on your front page and before the featured […]

Customizing the post layout (content, thumbnail) in post lists

Following the excellent javascript snippet from Rocco describing how to change the order of the content and the thumbnail, I’ll describe here the PHP way to hook into the property handling the post layout in post lists (archives, search results, …) and set new custom values, including mobile viewport detection.   By […]