Forum Replies Created

Viewing 15 replies - 121 through 135 (of 681 total)
  • I guess I misunderstood your request than. I thought you wanted two slides to share the same exact image. But I guess you needed a way to display featured images in your posts/pages and were asking if you can use slider images as featured images of posts/pages.

    Indeed. Ty EF. Should have re-read it after posting…

    I also found this tutorial which basically covers all the steps I mentioned above, walking you through the code. It’s all wrapped up in a plugin file, but it’s a custom plugin, one that you will create for yourself.

    You shouldn’t be afraid of plugins in general. They are the typical and recommended way of adding functionality that is not theme related to a website . As long as they do not have a lot of functionality you do not need or plan to use, you should not be afraid of plugins, especially high rated ones.

    Also, I have found out that dividing functionality mods to a website into self made custom plugin files, based on their scope, is a great way to keep everything in order. They’re easy to read, activate or disable.

    They are nothing more than simple php files with a plugin header, placed in /wp-content/plugins, nothing fancy. They’re not published on WP or anything, but I prefer this to having all mods mixed up in functions.php.

    I tend to keep functions.php for visual modifications only, which are theme related.

    You need more than one snippet for it:

    1. a snippet (or plugin) for adding custom post types
    2. a snippet (or plugin) for displaying custom slides which you need to populate with your testimonials (displaying their text, image, author name, maybe date, etc)…
    3. hooking the result from 2. somewhere in your homepage (I assume).

    If I was to do this asap, I’d probably use Custom Post Type UI plugin, even though I am quite familiar with register_post_type and I have used it in numerous ocasions (that is the WP function that allows you to add cpt’s programatically).

    For 2. I would probably use Advanced post slider as they advertise it works with custom post types. Another option is Recent Posts FlexSlider from WooThemes (it is also cpt capable).

    For 3. I would use this snippet:

    add_filter('tc_fp_block_display', 'content_after_fp');
    function content_after_fp($fp) {
    $after_fp = do_shortcode( '[advps-slideshow optset="1"]' );
    /*
     * Please note that [advps-slideshow optset="1"] is a shortcode
     * for advanced post slider, taken from their documentation.
     * If you choose to use another slider you need to find the
     * shortcode for that slider
    */
    
    return $fp.$after_fp;
    }

    Some more tweaking might be necessary in terms of styling and maybe the contents of each slide.

    If this seems like too much of a hassle, you might want to try out some of the ready made testimonial rotator plugins. I found about 3 that seem decent, but haven’t tried any.

    If you mean the top blue border, it can be disabled from theme options. “Disable top border” or something similar.

    If you mean the grey line between the logo and the slider, you need to add this to your custom css panel, in theme options:

    .tc-header { border-bottom: 0; }

    @media all and (min-width 980px) {
    .tc-header {
    	position: absolute;
    	background: transparent;
    	border-bottom: 0;
    }
    .navbar .navbar-inner {
    	background: rgba(255,255,255,.75);
    }
    }

    I have wrapped it up in a min-width: 980px conditional because it really messes up the header on narrow displays (so I only applied it on screens of 980px or higher).
    This goes in custom CSS panel or in your child theme’s style.css

    @deputy05: your solution only works on homepage. If you want it site-wide, you need to remove the .home selectors.

    I agree, mcfmullen.

    However, the slider in Customizr is a standard bootstrap 2.3.2. slider, not much to customize to it, except the contents of the slider title and its description. It has been built around the concept that each image is one slide (which kind of makes sense, if you ask me).

    I’m really curious about any other solutions that use the same image (as in the exact same file, so the browser doesn’t load two identical images) for different slides. That’s what you asked for, right?

    Thread Starter acub

    (@acub)

    d4z_c0nf solution is more flexible and indeed won’t break so easily on parent theme updates, unless the hook we use to switch the query is dumped from the theme (and that’s not likely to happen).

    As for understanding the code, the principle here is quite simple: we replace the main loop (in our case a single page loop) with a post loop (if we feed more query args to the query_post we can make it more specific (include/exclude cats, maybe query some custom post type instead of posts, etc…)).

    The wp_reset_query() switches back to the original page loop.

    If we make the switch soon, let’s say on init (when WP starts rendering the page), index.php will know we’re on a post list page and will render both slider and featured pages block.

    If we make the switch on __before_article_container we won’t have slider but we’ll have the featured posts loop.

    And if we do it on __before_loop we’ll only have the post list, without slider or featured posts block.

    Note: the solution using hooks to change the query should be done from functions.php, using the default template for the page and the function changing the query should have a conditional based on page id or slug.

    If you

    …want every post to have a slider and have every post appear on the homepage slider too…

    I suggest you disable the built-in slider of the first page, install a slider plugin that offers whatever you need from a slider and hook it up to some hook on first page.

    That’s how I would do it if the built in slider wouldn’t cut it for me. Well, to be honest, I’d just upload the same image multiple times and I’d go about my business 🙂

    The only real limit in web technology is the amount of effort you put into getting the result you want. The question here should not be: “Can this be done?”, but: “What’s the easiest way of achieving this result?”

    Here’s a couple of functions with their respective hooks that achieve what you need. Don’t forget to replace your-page-slug-or-id with the actual slug or id of the page that you want your blog posts displayed on. Replace it in both functions.

    This code should go in functions.php of your child theme:

    add_action('__before_loop', 'replace_page_query_with_blog');
    function replace_page_query_with_blog() {
    	if (is_page('your-page-slug-or-id') && is_main_query() && !is_admin()) {
    		query_posts('post_type=post&paged='. get_query_var('paged'));
    	}
    }
    add_action('__after_loop', 'reset_my_custom_query');
    function reset_my_custom_query() {
    	if (is_page('your-page-slug-or-id') && is_main_query() && !is_admin()) {
    		wp_reset_query();
    	}
    }

    First off, you need to have the testimonials in your database. You could add them as a separate category of normal posts but than you need to exclude that category from showing up from your blog, in all places your readers see your blog, including the rss feed. Another option, the proper one, is to add them as a custom post type.

    After you create the custom post type and you add a few testimonials, you need to add a function in your child theme’s functions.php that outputs the result of a query on those testimonials. And, of course, to add the result of that function to your front page, using a wordpress or theme hook.

    And, of course, you need to animate the elements, since you want them rotating, using some css 3 or jquery. You might want to regenerate the testimonials displayed from time to time and load the new results via ajax or you might want to generate all the slides when the page gets rendered and just iterate through those.

    This is all you need to do. It can all done be from functions.php but most parts of the process are easily achieved with WordPress plugins.

    Thread Starter acub

    (@acub)

    The problem with your solution is that it also adds the featured pages block, duplicating the home page, while the template solution only produces a blog list. But basically, they use the same method: they both replace the main (page) query with a blog query, maintaining pagination.

    But, than again, why are we talking about problems? There is no problem. If you look closely, this was originally posted as a how-to, because a lot of people were asking how to achieve this. Replacing the query or its parameters can be done in numerous ways: raw sql, changing query params with pre_get_posts, replacing the query based on page slug or page id (your solution) or templating (my original solution).
    I opted for the template solution as I find it more WordPress-like: it gives the user the ability to switch from blog to normal page from the page back-end, not from functions.php. Please note that I am usually a big fan of functions.php mods and child themes.

    Cheers.

    Remove “text-align: right;” from the current rule and add it in a separate declaration:

    .ie8 .site-description:after {
    	text-align: right;
    }

    Now it will only apply in IE 8.

    One more thing: the two images should have identical sizes, to avoid any complications.

    Here’s a working demo of the function. I replaced the 2nd image from the demo slider with the first:

    http://test.websiter.ro

    Here’s how you can do this and avoid having the same image loaded twice for a slider:
    1. Upload your image for the first slide. For this example, let’s assume you name it “qwertyuiop.jpg”.
    2. Upload another image, named “poiuytrewq.jpg” for the second slider you need “qwertyuiop.jpg” loaded.
    3. Now add this function to your child theme’s functions.php:

    add_filter('tc_slider_display', 'swap_slider_images');
    function swap_slider_images($html) {
    	return preg_replace('%poiuytrewq.jpg%', 'qwertyuiop.jpg', $html, -1);
    }

    Basically I’m switching “poiuytrewq.jpg” with “qwertyuiop.jpg” in the html output of the slider, just before it gets rendered in the page. If you need the image more than twice, replace the first argument of preg_replace with an array containing all the names that need to be replaced, like this:

    function swap_slider_images($html) {
    	return preg_replace(array('%specific-name-1.jpg%', '%specific-name-2.jpg%', '%specific-name-3.jpg%'), 'qwertyuiop.jpg', $html, -1);
    }

    Just make sure specific-name-{x}.jpg are specific enough that they don’t show up elsewhere in the html output for the slider (this includes the names of the slides, their descriptions and links, as well as the rest of html tags in the slider html output), except in those image names. If they do show up elsewhere in the slider, they will be replaced with qwertyuiop.jpg and will probably break your slider.

Viewing 15 replies - 121 through 135 (of 681 total)