Using bloginfo and divs inside a php file

I assume you’re wanting an image tag in there too: if ( $colors && in_array( ‘green’, $colors ) ) { echo ‘<div class=”asdsf”><img src=”‘; echo bloginfo(‘template_directory’) . ‘/path/within/theme/to/img.png’; echo ‘”></div>’; } But it’s better to use the newer get_stylesheet_directory_uri() which will work whether or not you are using a child theme. if ( $colors && … Read more

Show site content based on user role

You have errors in the code First, you are using current_user_can() function the wrong way. It has two parameters — $capability and $object_id. You don’t need the latter one, so, in your case: current_user_can(‘subscriber’) In my opinion, it’s better to use capability instead of user role in this function. For example, subscribers can’t edit posts, … Read more

Store and Change Session variable – PHP SESSION VARIABLE

Not sure if anyone understood my problem but if you did and are having something similar I will post how I figured it out. I simply had to add a session_start(); on my form.. <?php session_start(); //see here //this is the form that will change the variable if(isset($_POST[‘submit’])) { $the_user_garden = $_POST[‘sub_garden_1’]; } ?> <form … Read more

How to get current category

You can use get_queried_object(), which will return category object. See documentation: https://codex.wordpress.org/Function_Reference/get_queried_object

how to add re-order to wp user panel of wordpress?

You can re order admin left menu by below code: /* * Code below groups Dashboard/Posts/Pages/Comments together at the top of the dashboard menu. * If you were to have a custom type that you want to add to the group use the following edit.php?post_type=YOURPOSTTYPENAME */ function reorder_my_admin_menu( $__return_true ) { return array( ‘index.php’, // … Read more