Tag Info

Hot answers tagged

2

You are sort of doing this in a roundabout way. WordPress has a function called switch_theme(): add_action( 'setup_theme', 'switch_user_theme' ); function switch_user_theme() { if ( current_user_can( 'manage_options' ) ) { switch_theme('twentytwelve'); } else { switch_theme('twentythirteen'); } } The argument is the directory of the theme ...


2

It just take a little bit more complicated logic: function alternating_post_class($classes) { static $counter = 1; switch ($counter) { case 1: $classes[] = 'full-width'; break; case 2: case 3; $classes[] = 'half-width'; break; } $counter = ($counter == 3) ? 1 : $counter + 1; return $classes; } ...


2

I always break my functions.php up into more managable, specific functionality files, for instance, all footer related functions goes into a file called footer-functions.php and pagination functions goes into a file called pagination-functions.php. This way, my code stays organised, managable and I don't kill my functions.php. This however, is only related ...


2

You are missing the Template: definition in your stylesheet header. This is the folder name of the parent theme For instance, a child theme of the bundled theme will have the Template: defined as Template: twentyfifteen


1

The most common would be /wp-content/themes/your-theme-name/style.css but this may not be the case depending upon the theme you are using. The easiest way to find out is to use Chrome Developer Tools. In Chrome open your website and right click on the element you would like to alter the CSS for, then click 'Inspect Element'. The CSS files and classes which ...


1

Scripts should be enqueued on wp_enqueue_scripts action hook, which runs after init action. So dequeuing on init won't work because sripts are not enqueued yet. Before enqueued scripts are printed, wp_print_scripts action is triggered so you can dequeue or unregister scripts safely at this moment: add_action( 'wp_print_scripts', 'drw_timelinr_dequeue' ); ...


1

Your problem is that you've used the get_template_directory_uri() function for your include path. As indicated by the function name, this returns a URI (not a path), which is no use for including one php file into another. Simply enter the relative path of the file to be included. E.g. if your structure is: /my-theme |--functions.php |--/lib ...


1

This answer will be long, but can be helpful in some way. First of all, detect why you're getting this error: Majority of the time when you see a Wordpress' White Screen of Death, it means that you exhausted the memory limit of your server settings. This could be caused by a plugin that you may be using that is not functioning properly. It could also ...


1

See Wordpress Template Hierarchy and figure out which page you've to modify. From this figure, it's easy to see that if you want to modify your homepage, you have to modify frong-page.php. It it doesn't exist, check if a custom page template is used to serve the home page and edit that page template. If front-page.php doesn't exist and you are not using ...


1

Sounds like there are two parts to your query: 1) Stop the first post from showing the full content, and 2) show the featured image on all the posts. 1) At the moment, the first post is using a different template to the other posts. To make the posts consistent, change this in index.php: get_template_part( 'content' ); to this: get_template_part( ...


1

The current WordPress theme name is saved in the wp_options table of your WordPress database. The easy way to do it is to use the update_option() function, as shown in the function below. Paste it in your functions.php file. function updateTheme($theme){ update_option('template', $theme); update_option('stylesheet', $theme); ...


1

Change the action to 'init': class My_Plugin { public function __construct() { add_action( 'init', array( $this, 'overwrite_wptheme_settings' ) ); } public function overwrite_wptheme_settings() { add_image_size( 'tie-small', 70, 70, false ); } }


1

According to WordPress template hierarchy, the page templates will fall back to page.php of the new (active) theme. You can read more about template hierarchy here:- https://developer.wordpress.org/themes/basics/template-hierarchy/


1

Its just personal preference. People do like to design stuff in watever way they want. However, the boxed design does limit the dimensions of your images to something much narrower than what you will use in a full screen or wider design. Also, the stretched layout needs less worrying about different breakpoints.



Only top voted, non community-wiki answers of a minimum length are eligible