• Resolved JapeNZ

    (@japenz)


    Hi there,

    Is there a snippet I could use to add text before the Products Per Page dropdown?

    I’d like to use your Changing the text in the dropdown guide so the dropdown just has the numbers, and add the text ‘Products per page’ infront of the dropdown.

    Thank you for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    I don’t have a snippet readily available for this unfortunately.

    Cheers,
    Jeroen

    Thread Starter JapeNZ

    (@japenz)

    HI @sormano,

    I think I’ve managed to create a workaround using your Changing the text in the dropdown and some css.

    Here’s what I’ve done with the changing text filter:

    add_filter( 'wppp_ppp_text', 'wppp_custom_text', 10, 2 );
    function wppp_custom_text( $text, $value ) {
    	if ( $value == '20' ) {
    		return '20';
    	}
    	if ( $value == '40' ) {
    		return '40';
    	}
    	if ( $value == '60' ) {
    		return '60';
    	}
    	if ( $value == '80' ) {
    		return '80';
    	}
    	if ( $value == '100' ) {
    		return '100';
    	}
    	return 'Display %s products';
    
    }

    and here’s the css:

    form.form-wppp-select.products-per-page {
        margin: 2px 0px 10px 10px;
        width: 185px;
    }
    
    .products-per-page::before {
        content: 'Products per page';
        margin: 0 5px;
    }
    
    select.select.wppp-select {
        padding: 4px 6px;
        border-radius: 2px;
        border-width: 1px;
        border-style: solid;
        border-color: rgb(169, 169, 169);
        max-width: 60px;
    }

    Here’s the result:

    Does this code look okay, or is there a better way to do this do you think?
    I don’t have much experience with this sort of thing, so this is pretty much cobbled together from various things I found online xD

    Thanks again for your help!

    • This reply was modified 1 year, 5 months ago by JapeNZ.
    Plugin Author Jeroen Sormani

    (@sormano)

    If it works, it works!

    Often there’s more than one way of doing things, this looks fine ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add text before dropdown’ is closed to new replies.