Hot answers tagged

9

Best place is the uploads directory - it'll be writable by the server, and it's the defacto directory for storing any user-generated/uploaded files: $dirs = wp_upload_dir(); $path = $dirs['basedir']; // /path/to/wordpress/wp-content/uploads


3

The only directory with guaranteed write access is the upload directory. Everything else might be protected. Nowadays, we deploy sites with Composer, keep everything under version control and create completely new sites with each deploy in order to be able to roll back the deployed site. That means that the directory will be created completely new with ...


3

How often are the theme mods changed? A lot in the design phase, maybe a couple of times later on. Always by admins, never by ordinary users, let alone visitors. So, it doesn't make sense to generate the full css at every pageload. A better approach is to generate the css only for the admin and store the result for others. This will reduce the amount of ...


3

You'll be unable to automatically update the parent Divi theme when it's directory becomes renamed. You can use any of caching​ plugins with CSS minify or/and CSS combine turned ON. This way everybody will see /cache directory instead of the actual theme directory. Or as the alternative, you can update renamed parent theme manually, directory by directory, ...


3

Here's one idea, that might need further testing: /** * Cropped header image with the same description/caption as the original image */ add_filter( 'wp_create_file_in_uploads', function( $cropped, $attachment_id ) { add_filter( 'wp_insert_attachment_data', function( $data ) use ( $attachment_id) { if( doing_action( ...


2

You may want to look at the TwentySixteen theme, which does it this way: In single.php: get_template_part( 'template-parts/content', 'single' ); Several templates are grouped in the 'template-parts' folder. You could use a similar logic for your custom post type. It seems that the technique comes from _underscores.


2

Do you understand the bootstrap framework at all? Your theme has implemented a column width that is smaller than you would probably like. Your content area is wrapped in an offset column that is 50% of the container width. <div class="col-lg-6 col-lg-offset-3"> <!-- content --> </div> If you want to increase the width of your ...


2

1. By definition The article element represents a complete, or self-contained, composition in a document, page, application, or site and that is, in principle, independently distributable or reusable, e.g., in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, ...


2

I was able to figure this out and make it dynamic. I created a variable $template that I put inside the loop, in which I stored the page template. $template = get_post_meta( $post->ID, '_wp_page_template', true ); Then, I utilize this where I need the child pages to show up. <?php include(locate_template($template)); ?> This is working for me ...


1

The default Wordpress themes, from Twenty Eleven onwards, support varying degrees of responsive design, including menus, and any child themes will automatically inherit this behaviour, unless the child theme does something to override it. It is possible to create menus in your theme using wp_nav_menu that can then be hidden or displayed for various screen ...


1

get_the_content doesn't apply all of the filters that the_content runs before outputting the result. You can fix this by simply using: <?php the_content(); ?> in place of: <?php echo $content; ?> If you look at the source for the_content, you'll see the extra step it performs on what is returned from get_the_content.


1

It's outputting the word Array which is self explanatory. Instead of direct echoing it, you will need to turn the array into a string. Try implode, something like: Tags: <?php $my_theme = wp_get_theme(); echo implode(', ', $my_theme->get( 'Tags' ) ); ?>


1

The question you linked to doesn't quite do what you're wanting - it allows you to get the template assigned to a page you're querying, but what you're actually wanting is to get a page assigned to a particular template. You can do this using the get_pages() function by querying a meta key of the page. Pages/posts can have a range of fields assigned to ...


1

You would have to rename the directory of the Divi theme. However, this could break the theme if there are components that depend on the directory being named Divi. Also, there may be copyright issues.


1

WP inherently supports multiple theme directories via register_theme_directory(). However since it requires web–accessible directory you might have to symlink or otherwise muck with it server–side so that all sites pick it up. Up to your configuration how to do it exactly.


1

You can deregister that style in your child theme functions.php function remove_shoreditch_background() { wp_deregister_style('shoreditch-style'); } add_action('wp_enqueue_scripts', 'remove_shoreditch_background'); Or you could remove that action entirely remove_action('wp_enqueue_scripts', 'shoreditch_post_nav_background'); Or you can just ...


1

If your theme fully supports child themes copy template-tags.php to the child theme folder and edit it as needed.


1

It's not classified as plugins. It's also not a WordPress glossary and often called: Tabs which are built on Settings API and some tricks with $_GET request. There're many Q&As, references you can learn from. This topic seems to be the most relevant one for you. Yes, you can do it with template_include filter. These Q&As may be helpful too.


1

One alternative approach us to have a PHP file that gets the theme options and outputs the CSS and enqueue that directly instead. eg. wp_enqueue_style('custom-css',trailingslashit(get_template_directory_uri()).'styles.php'); This may seem like a strange thing to do at first, but since actually writing a new file should be done via the WP Filesystem for ...


1

Something went wrong with your installation. As commented by @Sumit get_header() is a core function and cannot be undefined. To troubleshoot: Reinstall WordPress and enable WP_DEBUG in wp_config.php: define( 'WP_DEBUG', true ); If it is on a live site you might want to use this instead: define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ...


1

If you want the WordPress framework without the querying, use wp-load.php: require '/path/to/wordpress/wp-load.php';


1

I think you are referring to starter themes also called skeleton themes. I have used a couple in the passed. Bones Underscore There are many others out there. Try and google: "skeleton theme wordpress" for more results


1

I agree with Mark that it's not the best idea i've ever heard of, but it is easily done, by defering everything to index.php. Start that file as follows: if (is_404() and file_exists (get_template_directory() . '/wp_template_parts/404.php') {get_template_part (get_template_directory() . '/wp_template_parts/404.php');} elseif (is_page() ... and so on ... ...


1

Yes it is a bad idea. There are de facto standards on code organization in themes, and no one likes to figure out the code of someone else that thought that he is smarter than all WP developers before him, even if it is possible code wise to do it differently. So unless you are planning to be the only one ever that works on that theme, please follow ...


1

In author.php: <?php get_template_part('custom-author-file'); Alternatively, rename your custom-author-file.php to author.php. The URL being used in this case isn't relevant, as a template doesn't determine the URL used, it's the other way around. However, I suspect there is more to your question you haven't explained


1

If you have successfully uploaded the theme via FTP into the correct directory it should be available to activate. Things to check: Using your FTP client, you should be able to see the theme directory and all its files under wp_content/themes Make sure the file permissions are correct for WordPress to be able to access the files (you may need to check ...



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