Gareth Gillman
  • Member for 8 years, 7 months
  • Last seen this week
Integrate WooCommerce theme with a Wordpress theme
Accepted answer
4 votes

I would add it from the start so you don't have to go back to it, and it's a really simple process of creating a woocommerce.php file in your theme and then add the following to your functions.php ...

View answer
Display sidebar if blog
Accepted answer
3 votes

There is no conditional tag for the blog page. You have to use both is_home() and is_front_page() to detect this page When you use is_home() and is_front_page(), you have to use them in the right ...

View answer
Cannot retieve the_content() and the_author() - both returning empty strings
Accepted answer
3 votes

get_the_content and the_author have to be in a loop so you would need to use other functions to get the content you need global $wp_query; $post = $wp_query->post; $page_id = $post->ID; // page ...

View answer
Get latest posts from multiple categories
Accepted answer
3 votes

2 choices here, you either need to set the category as an array e.g. $args = array( 'posts_per_page' => 5, 'category' => array(15,16,17,18,19) ); You can't just add the numbers in a list ...

View answer
Problem with comments_number()
3 votes

You want to use get_comments_number() as that doesn't echo the results, while comments_number does echo

View answer
Adding in support thumbnail removes editor
Accepted answer
3 votes

You need to add each individual support you need e.g. 'supports' => array('thumbnail', 'title', 'editor'), The title and editor are added by default in a post type but if you add the supports ...

View answer
Pull Custom /wp-admin/css for Non-Admin in Multisite
Accepted answer
3 votes

Something like the following should work: global $blog_id; if ($blog_id == 1) { wp_enqueue_style( 'custom-style', '/wp-content/css/new_styles.css' ); } Basically it checks if the person is on ...

View answer
Setting up the child theme so as to enable right-to-left WordPress?
Accepted answer
2 votes

You also need to include the RTL.css file which is in the theme too: add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); function my_theme_enqueue_styles() { wp_enqueue_style( 'parent-...

View answer
Consolidating two websites into one, but migrated images not appearing in Image Library
Accepted answer
2 votes

By default, when you upload an image via the admin, it's metadata is added to the database, and that's how you can search through them in the media library etc. If you upload images via ftp then they ...

View answer
Load custom posts with same tag as page
2 votes

My first port of call is to call global $post; - as that sets you up to use $post->ID ... if you are using it then the next step is to display each part separately e.g. print_r($tags); echo $...

View answer
Set a static front-page as a landing page programmatically
Accepted answer
2 votes

You can do it by targeting get_option('show_on_front'); some code which could help would be: function themename_after_setup_theme() { $site_type = get_option('show_on_front'); if($site_type == '...

View answer
Internal Stylesheet in Wordpress Theme development
2 votes

what do you mean by internal? do you mean in the header? If it's in the header then you should be fine but it depends on how you add to the header. What you would ideally be doing is adding it to the ...

View answer
How to remove text "Log In" from login page
2 votes

I would just use CSS to hide it: #theme-my-login1 #header-element { display:none; } Add to the login page by using a function / filter e.g. function custom_login_css() { echo '<style type="...

View answer
Wordpress register_post_type Invalid post type
Accepted answer
2 votes

If you can't get the "talent" post type to register, set the name to artist and then using the Rewrite option for the CPT e.g. 'rewrite' => array( 'slug' => 'talent' ), That will give you the ...

View answer
Hide Default Video Shortcode Controls on PageLoad
2 votes

You need to use the hover CSS code to enable it e.g. .mejs-container .mejs-controls:hover { display:block; }

View answer
paypal buynow button integration with wordpress for digital download
2 votes

It's far better to use a plugin such as Easy Digital Downloads as there are many steps you will need to code in e.g. 1) Check if user has paid (by checking if they were referred back successfully by ...

View answer
Enqueue script only when side widget is used
1 votes

is_widget_active is what you want e.g. function sidedish_slide_script() { wp_register_script('add-sd-js', get_template_directory_uri() . '/form-slider/jquery-1.8.2.min.js', array('jquery'),'null', ...

View answer
How to exclude post body from WP search
1 votes

To remove elements from being searched, use the post_search filter to amend the SQL query for the search e.g. only pull in the title. function ni_search_by_title_only( $search, &$wp_query ){ ...

View answer
How to pre-fill Google Forms URLs with logged-in WordPress user's data
1 votes

AS easy as you said: $user = wp_get_current_user(); if(!empty($user)) { $email = $user->user_email; $fname = $user->user_firstname; $sname = $user->user_lastname; $url = 'https://docs....

View answer
Get all meta keys assigned to a post type
1 votes

query all posts in the post type and then get the meta keys from the posts e.g. Not tested, may need some amendments $meta_fields = array(); $the_query = new WP_Query( 'post_type=posttype' ); if ( $...

View answer
Add post type pages with plugin
Accepted answer
1 votes

You can't without hooking a filter to recognise the files in your plugin BUT you can hook into the template_include filter and register your own file e.g. add_filter('template_include', '...

View answer
Wrap every 2 divs in row - for each loop
Accepted answer
1 votes

You need to create a variable with the count and then check against it e.g. $num = 1; foreach ( $terms as $term ) { if($num%2) { echo '<div class="something">'; } // other stuff if($...

View answer
Trying To Get Child Categories To Show, Issue With foreach Loop
Accepted answer
1 votes

Do the categories all have posts, change line 2 to: $categories = wp_list_categories('hide_empty=0&title_li=0&child_of='.$categoryslug->term_id'); This sets it to display all categories ...

View answer
Using Conditionals when homepage is a page and blog is /blog
Accepted answer
1 votes

is_home is the check you need to use if the page is set to be the blog page in settings > reading <?php if(is_home()) { // do something } else { // do something } ?>

View answer
Force Jetpack to not use og:image tag for favicon / Site Icon
1 votes

If you know the name of the function that is adding the meta tag (and it's added in it's own). function se_remove_meta() { remove_action('wp_head', 'function_name'); } add_action( 'init', '...

View answer
Exclude latest post from WP_Query taxonomy term loop
Accepted answer
1 votes

wp_query has the offset parameter which you can use to skip posts, e.g. $args = array( 'post_type' => 'video', 'tax_query' => array( array( 'taxonomy' => 'tax-video', 'field' =&...

View answer
How to show 50×50 image thumbnail in Related Post
Accepted answer
1 votes

Change: the_post_thumbnail() To: the_post_thumbnail( array(50, 50) ); It's all documented on the codex / developer site at https://developer.wordpress.org/reference/functions/the_post_thumbnail/

View answer
Populate dropdown from one custom post type inside another custom post type
1 votes

You need to query the db using wp_query to get all the posts from the CPT, save the metabox contents to an array and then print the array. Not tested but should work (i hope): <?php $select_array ...

View answer
Delay JavaScript files from loading
1 votes

change the action to: add_action('init', array($my_class, 'pluginInit','40')); That tells the action to run much later in the queue, you could also check if the other script has been enqueued by ...

View answer
Why is wp-login trying to send an email?
1 votes

wp-login is the file used to send user passwords e.g. new user registrations user lost passwords It might be you're getting a lot of registration spam? Is registration turned off on your install (...

View answer