New answers tagged

0

NOTE the difference between add_meta_boxes and register_meta_box_cb. When you register the meta boxes using add_meta_boxes, here is how WordPress calls do_action() /** * Fires after all built-in meta boxes have been added. * * @since 3.0.0 * * @param string $post_type Post type. * @param WP_Post $post Post object. */ do_action( ...


1

Post type names cannot contain capital letters. So behind the scenes, your CPT is probably called projectscpt rather than ProjectsCPT - hence it not matching the value in your array.


0

There are two ways to solve this: 1 Keep the mods as they are and use get_theme_mod in stead of get_option 2 Store the mods as options by changing the setting: $wp_customize->add_setting( 'social_link_facebook' , array( 'default' => '', 'type' => 'option' ) );


0

I just added the id (#login h1 a) to the function and that worked fine. function my_login_logo() { ?> <style type="text/css"> #login h1 a, .login h1 a { background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/login-logo_320px.png); padding-bottom: 30px;background-size:160px ...


0

If space were the only problem you could simply enqueue a css file to the admin area with these lines to expand the width of the customizer panel from the usual 300px to 500px: .wp-full-overlay-sidebar {width 500px !important;} .wp-full-overlay.expanded {margin-left:500px !important;} Hey, you could even enqueue a js file to insert a button to toggle ...


1

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 ...


0

I don't know what our single-XXX.php files look like, but if they include calls to get_header (and perhaps get_sidebar()and get_footer) you obviously will get the header twice as it is called again at the bottom of your first code block (and perhaps te rest of the regular page). In the second code block you avoid outputting the header twice, because it is ...


0

1 Always have the latest WP build in your development install and make sure you have Theme Check installed. Check at every major release. That's the obvious one. 2 If you incorporate any external scripts or services in your theme, check these at least once a month. There may be security issues (as with the notorious tim thumb script). Also, your users may ...


0

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 ...


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

You can prevent adding a script to a specific WordPress page by checking if whether we are on that page or not is_page($page_id): function add_js() { wp_deregister_script('jquery'); wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", false, null); ...


1

In answer to my question (and in case anyone is interested), this seems to be the best solution: <?php $service_meta = get_post_meta(get_the_ID()); ?> <p><?php echo $service_meta['_cmb2_service_name'][0]; ?></p>


2

If you really want to be on-the-ball then test all of your plugins and themes against the RC versions of WP when they become available. You're right that using the debugging plugins and looking out for deprecations should let you keep things up-to-date. The release announcements usually show up on https://wordpress.org/news/category/releases/


1

The left padding will be the default 40 pixels added to a ul by the browser. When I style WP menus I use this to make sure all browsers are happy: .blog-nav li, .blog-nav ul { padding: 0; margin: 0; }


0

Yo might want to have a look at this post: Getting taxonomy terms used by custom post type You can include the empty terms by passing 'hide_empty' => 0,.


1

I am adding another answer to answer this question:- How to exclude certain widget from showing up on home/front page? WordPress has an internal function _get_widget_id_base() I am not sure how safe to use it. But this is the method which WordPress uses to get widget ID base by using widget ID instead of strpos() and strncmp(). Example:- ...


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, ...


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.


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 ...


0

At the moment it is simply not possible to have more than panels, sections and controls. Expanding this system would require extensive programming at WP. Given the narrow size of the customizer you could also easily get lost if you have so many nested panels. So it's probably not desirable either.


0

I have found that some new programmers are trained this way. I'm following a 40 hour course on Lynda and the instructor is dropping PHP tags on every line, with the exception of function definitions. It's probably to clearly draw lines between HTML and PHP, which probably helps new people understand where HTML ends and PHP begins. After that, its ...


2

You need to use two underscores __('String to be translated', 'textdomain') Also, it looks like you're not using the textdomain in the right way


0

Your page is loaded with jQuery errors (not using no-conflict), and additionally your isotope.js doesn't appear to be in no-conflict. This is why you're getting errors like $ is undefined. Once you fix your jQuery by either replacing the $ with jQuery or wrapping your functions in (function($) { $('selector');// Now you can use the $ to do whatever you ...


1

In your function.php you can add a custom size, for example: add_image_size ('custom_thumbail', 200, 200); Then once you regenerate thumbnails (recommended plugin by wordpress) it will create these, or any new uploaded images will have this size. Then you can call them in your post. Echo wp_get_attachment_url('your post id', 'custom_thumbail'); ...


1

I use the Aqua Resizer in my theme development. https://github.com/syamilmj/Aqua-Resizer It's pretty easy to implement, and it should do exactly what you want. This function will allow you to resize any existing WordPress image. The below example would create a 200 x 200 image from the WP Medium image, and hard crop it to 200 x 200. $thumb = ...


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

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 ...


2

set_post_thumbnail_size() (and other API functions which add/change sizes) applies to generation while it's active. So existing generated image sizes won't be retroactively affected by it. There are plenty of tools around (plugins, wp-cli) which regenerate files with current sizes configuration.


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 ...


8

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


0

I think the best place to write to is to add a folder in the wp-content folder. Here you can write your css files without it is being overwritten when you have a theme update or have a WP update.


1

I get that answer. I go to this file: wp-includes/deprecated.php and find this line in (deprecated) wp_get_http() function: @set_time_limit ( 60 ); just comment out this line and it works fine. Because wordpress hard coded that 60 seconds limit, this hard coded setting was over-ridding my php.ini settings. so I comment out that line, my php.ini ...


-1

You can create using page builders as well as using widgets or you can use custom post types and create page templates for different pages of your custom WordPress theme website.


0

Here is version for any post type, in case if you are using custom post type function has_children($post_ID = null) { if ($post_ID === null) { global $post; $post_ID = $post->ID; } $query = new WP_Query(array('post_parent' => $post_ID, 'post_type' => 'any')); return $query->have_posts(); }


2

First off, ensure that the category is exactly the same name as the page ( slug and all ). Secondly, the parameters you're passing to WP_Query is incorrect. category_name expects a slug. For example, Page 1 would have a slug of page-1. get_the_title() pulls the current page title - so you're passing Page 1 to a parameter that expects a slug page-1. What ...


0

Have you considered to learn how to develop WordPress sites before working with a client? And you can always go with a child-theme from one of the WordPress default themes or you can start from scratch following this tutorial :)


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

Although overriding the function in a child theme is often a good way to go, it looks like this theme doesn't set that up with this particular function (because they're not checking if function_exists() first, before redefining it - which will cause an error). However, they have given you a way of overriding it with filters. At the bottom of their ...


3

If the theme repository is anything like the plugins one, content that hasn't been updated in a while gets hidden, even if it still works. Its probably a good idea to check themes and plugins at least once a year against the latest version, update their meta information, and check them into the repository as an update, even if no functional changes needed to ...


0

@Dan meant this: <nav role="navigation" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement"><?php wp_nav_menu([ 'container' => '', 'items_wrap' => '<ul>%3$s</ul>', ... ]); ?></nav>


1

Only to append the solution from @luis-sanz, I will add the note that every theme has to have the style.css file enqueued. Following the example https://codex.wordpress.org/Function_Reference/wp_add_inline_style from the codex, we can use get_stylesheet_uri() function and append the dynamic CSS data using the wp_add_inline_style function in the following ...


1

wp_add_inline_style needs to be tied to an existing stylesheet in order to work properly. The inline styles will only be printed when the stylesheet they are attached to is enqueued. This is quite handy to control the scope of the inline styles. If the idea is to have them printed globally, the safest handle to tie them to is that of the active theme main ...


-1

Dipika use CSS to implement this instead of PHP codes. Use / as the background of li and set this to the position left top. Set background none for the first-child li


0

As @N00b pointed out this can go in many answers and needs many concepts digestion.I will try to concise and give a sample answer with little info. Since you have set has_archive to true while registering post type , we can see all treatment post-type post on example.com/treatment/. If we want to change this page to display just taxonomy categories list, we ...


0

If you want to be super safe, you can do this method: I would recommend first connecting to the theme folder via FTP. If you haven't made any templates or custom php pages etc, you can rename the theme folder _backup at the end. Then just drag in the new theme in the same theme folder location. Simply go to your dashboard and activate the new theme. ...


0

Answer by Implode solve issue only if you are not using other queries like 'meta_key' even . I found complete solution here. function fix_nav_menu( $query ) { if ( $query->get( 'post_type' ) === 'nav_menu_item' ) { $query->set( 'tax_query', '' ); $query->set( 'meta_key', '' ); $query->set( 'orderby', '' ); } } ...


0

What happens depends on the changes made to the parent theme. The developers should of course make certain that their new version is backwards compatible, so your child theme still works with the updated parent. However, this is not necessarily so. Therefore, you should test the updated parent with your child theme before you apply it to a live site.


-1

Without installing any plugin we can add the social bookmarks. I found following article for this. adding social share buttons without wordpress plugin



Top 50 recent answers are included