qid
int64
4
8.14M
question
stringlengths
20
48.3k
answers
list
date
stringlengths
10
10
metadata
list
input
stringlengths
12
45k
output
stringlengths
2
31.8k
172,443
<p>Is there any way to see what .php files are being loaded for a particular page? </p> <p>So say I have a page - www.example.com/page - and on it is loading the header.php, sidebar.php, footer.php, and the page.php, and any other php from plugins. Is there anyway to get a list of these for a certain page?</p>
[ { "answer_id": 172445, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 2, "selected": false, "text": "<p>The following will show the current template file to logged in admins only. If you add to the top of your fu...
2014/12/16
[ "https://wordpress.stackexchange.com/questions/172443", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56659/" ]
Is there any way to see what .php files are being loaded for a particular page? So say I have a page - www.example.com/page - and on it is loading the header.php, sidebar.php, footer.php, and the page.php, and any other php from plugins. Is there anyway to get a list of these for a certain page?
The following will show the current template file to logged in admins only. If you add to the top of your functions file, you should see this info as the first line. ``` add_action('wp_head', 'show_template'); function show_template() { global $template; global $current_user; get_currentuserinfo(); if ($curre...
172,467
<p>I have a custom taxonomy called 'industry' that I want to use on custom post type 'website-design'. It works on the intended post type, but other pages are broken. I changed the 404 template as per <a href="https://stackoverflow.com/questions/13645721/wordpress-taxonomy-causing-pages-to-404">this question</a>, and d...
[ { "answer_id": 172469, "author": "tylershuster", "author_id": 60202, "author_profile": "https://wordpress.stackexchange.com/users/60202", "pm_score": 0, "selected": false, "text": "<p><em>The issue appears to have resolved itself</em></p>\n\n<p>I had some custom permalink function rewrit...
2014/12/16
[ "https://wordpress.stackexchange.com/questions/172467", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60202/" ]
I have a custom taxonomy called 'industry' that I want to use on custom post type 'website-design'. It works on the intended post type, but other pages are broken. I changed the 404 template as per [this question](https://stackoverflow.com/questions/13645721/wordpress-taxonomy-causing-pages-to-404), and discovered this...
Create file called `taxonomy-industry.php` and copy your `archive.php` into it. I faced the same proplem with my site and that solution worked for me. Hope it works for you
172,468
<p>In my header.php I have the typical header code - this is for woocommerce but the coding has nothing to do with it:</p> <pre><code>&lt;h1 class="page_title"&gt;&lt;?php woocommerce_page_title(); ?&gt;&lt;/h1&gt; </code></pre> <p>Now I have edited that somewhat to show as:</p> <pre><code>&lt;table style="backgroun...
[ { "answer_id": 172469, "author": "tylershuster", "author_id": 60202, "author_profile": "https://wordpress.stackexchange.com/users/60202", "pm_score": 0, "selected": false, "text": "<p><em>The issue appears to have resolved itself</em></p>\n\n<p>I had some custom permalink function rewrit...
2014/12/17
[ "https://wordpress.stackexchange.com/questions/172468", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56659/" ]
In my header.php I have the typical header code - this is for woocommerce but the coding has nothing to do with it: ``` <h1 class="page_title"><?php woocommerce_page_title(); ?></h1> ``` Now I have edited that somewhat to show as: ``` <table style="background-image: url('url');><tr><td><?php woocommerce_page_title(...
Create file called `taxonomy-industry.php` and copy your `archive.php` into it. I faced the same proplem with my site and that solution worked for me. Hope it works for you
172,492
<p>Could somebody tell me what's wrong with my WP query please? I'm trying to order my posts by price and price is an ACF (a textbox which has a number in it)</p> <pre><code> $args = array ( 'post_type' =&gt; 'product', 'post__in' =&gt; $post_ids, 'po...
[ { "answer_id": 172493, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 0, "selected": false, "text": "<p>You don't need <code>meta_query</code> in your code. And also you don't need to check numeric value of met...
2014/12/17
[ "https://wordpress.stackexchange.com/questions/172492", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64914/" ]
Could somebody tell me what's wrong with my WP query please? I'm trying to order my posts by price and price is an ACF (a textbox which has a number in it) ``` $args = array ( 'post_type' => 'product', 'post__in' => $post_ids, 'posts_per_page' => -1,...
`'meta_value_num'` - Order by numeric meta value (available with Version 2.8). Also note that a `'meta_key=keyname'` must also be present in the query. This value allows for numerical sorting as noted above in `'meta_value'`. Try to use like this : ``` $args = array ( 'post_type' => 'product', ...
172,509
<p>I've recently installed a couple of apps (WordPress and BlogPad Pro) and I'm a bit surprised to see that they can indeed post to my blogs, even though I haven't given them the renamed login and wp-admin pages that I set up through iThemes Security. </p> <p>My understanding was that posting could only happen "throug...
[ { "answer_id": 172512, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>Clients typically use <a href=\"http://codex.wordpress.org/XML-RPC_Support\" rel=\"nofollow\">XML-RPC Support</a>.</...
2014/12/17
[ "https://wordpress.stackexchange.com/questions/172509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59139/" ]
I've recently installed a couple of apps (WordPress and BlogPad Pro) and I'm a bit surprised to see that they can indeed post to my blogs, even though I haven't given them the renamed login and wp-admin pages that I set up through iThemes Security. My understanding was that posting could only happen "through" the bac...
Clients typically use [XML-RPC Support](http://codex.wordpress.org/XML-RPC_Support). If you take a look at your page source you will likely see endpoint declaration: ``` <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://example.com/xmlrpc.php?rsd" /> <link rel="wlwmanifest" type="application/wlw...
172,524
<p>We've been storing all of our images using the default /year/month/day, but I'm thinking there has to be a better way to store things because everytime that I update a image or pdf. I have to reupload it and it gets stored in a new location.</p> <p>We occasionally get in the situation where we update a pdf that was...
[ { "answer_id": 172512, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>Clients typically use <a href=\"http://codex.wordpress.org/XML-RPC_Support\" rel=\"nofollow\">XML-RPC Support</a>.</...
2014/12/17
[ "https://wordpress.stackexchange.com/questions/172524", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12321/" ]
We've been storing all of our images using the default /year/month/day, but I'm thinking there has to be a better way to store things because everytime that I update a image or pdf. I have to reupload it and it gets stored in a new location. We occasionally get in the situation where we update a pdf that was uploaded ...
Clients typically use [XML-RPC Support](http://codex.wordpress.org/XML-RPC_Support). If you take a look at your page source you will likely see endpoint declaration: ``` <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://example.com/xmlrpc.php?rsd" /> <link rel="wlwmanifest" type="application/wlw...
172,544
<p>I'm not trying to set the exerpt for a custom post type, but a word limit in the admin of my custom post type.</p> <p>I have just set up a custom post type:</p> <pre><code>add_action( 'init', 'test_post_type' ); function create_post_type() register_post_type( 'test_post_type', array( ...
[ { "answer_id": 172553, "author": "IntricatePixels", "author_id": 9748, "author_profile": "https://wordpress.stackexchange.com/users/9748", "pm_score": 0, "selected": false, "text": "<p>Personally I would not recommend making any such changes to the default way the Wordpress editor works ...
2014/12/17
[ "https://wordpress.stackexchange.com/questions/172544", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64933/" ]
I'm not trying to set the exerpt for a custom post type, but a word limit in the admin of my custom post type. I have just set up a custom post type: ``` add_action( 'init', 'test_post_type' ); function create_post_type() register_post_type( 'test_post_type', array( 'labels' => array...
Filters and Actions ------------------- The hooks you can chose to run whatever limits the post content length from, is either `save_post`, `save_post_{post_type}` or `edit_post` (or both) (the following actions are executed inside [`wp_publish_post()`](https://github.com/WordPress/WordPress/blob/48620242c4571631c6f13...
172,557
<p>I am trying to display an post to my home page based on a selection. What I mean is in the backend I have a custom post that has a metabox labeled Assign to Home with a drop down that has a selection of Yes or No. What I am trying to do is when a custom post has a selection of Yes it will be displayed on the home pa...
[ { "answer_id": 172581, "author": "mrbobbybryant", "author_id": 64953, "author_profile": "https://wordpress.stackexchange.com/users/64953", "pm_score": 3, "selected": true, "text": "<p>I looks like you are using the custom meta boxes and fields github repo, which is an awesome library. I ...
2014/12/17
[ "https://wordpress.stackexchange.com/questions/172557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54798/" ]
I am trying to display an post to my home page based on a selection. What I mean is in the backend I have a custom post that has a metabox labeled Assign to Home with a drop down that has a selection of Yes or No. What I am trying to do is when a custom post has a selection of Yes it will be displayed on the home page....
I looks like you are using the custom meta boxes and fields github repo, which is an awesome library. I think the primary thing you need to do is a new WP\_Query. Below is an example of that in action. The only difference is that in my example I made the "Assign to Homepage" a checkbox on the custom post type. ``` <?p...
172,576
<p>In the logic of the data_query(); I found this WP_Query sample:</p> <pre><code>&lt;!-- Second Senses Featured --&gt; &lt;ul id="featuredSecond" class="featured-second"&gt; &lt;?php $today = getdate(); $args = array( 'tag_slug__in' =&gt; array( 'destacado'), 'posts_per_page' =&...
[ { "answer_id": 172578, "author": "mrbobbybryant", "author_id": 64953, "author_profile": "https://wordpress.stackexchange.com/users/64953", "pm_score": -1, "selected": false, "text": "<p>Try replacing <code>getdate()</code> with <code>current_time('Y-m-d')</code></p>\n" }, { "answ...
2014/12/18
[ "https://wordpress.stackexchange.com/questions/172576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57716/" ]
In the logic of the data\_query(); I found this WP\_Query sample: ``` <!-- Second Senses Featured --> <ul id="featuredSecond" class="featured-second"> <?php $today = getdate(); $args = array( 'tag_slug__in' => array( 'destacado'), 'posts_per_page' => 2, 'post_type' => 'an...
I don't think there is a parameter value `Today` as you used in `date_query`. If you want to return today's post then you should provide date value to `date_query` as you stored current date in `$today` array. So here is your query now. ``` $today = getdate(); $args = array( 'tag_slug__in' => arra...
172,582
<p>Is there a way to change the html of my wordpress page's navigation bar? (I'd like to add in several divs that will be controlled with media queries.)</p> <p>Thanks for reading!</p>
[ { "answer_id": 172585, "author": "Karun", "author_id": 63470, "author_profile": "https://wordpress.stackexchange.com/users/63470", "pm_score": 3, "selected": false, "text": "<p>Yes, you'll need to implement the walker class for this. </p>\n\n<p>Here is a simple example.</p>\n\n<pre><code...
2014/12/18
[ "https://wordpress.stackexchange.com/questions/172582", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64956/" ]
Is there a way to change the html of my wordpress page's navigation bar? (I'd like to add in several divs that will be controlled with media queries.) Thanks for reading!
Yes, you'll need to implement the walker class for this. Here is a simple example. ``` $defaults = array( 'theme_location' => 'primary', 'container' => 'ul', 'menu_class' => 'nav navbar-nav main-nav', 'walker' => new Primary_Walker_Nav_Menu() ); wp_nav_menu( $defaults ); ``` In th...
172,609
<p>I have an existing widget area / sidebar. Rather than adding content to it via Appearance ? Widgets in the Dashboard, I want to inject content into the widget area from functions.php.</p> <p>Is there hook that allows this?</p> <p>Thanks :)</p>
[ { "answer_id": 172585, "author": "Karun", "author_id": 63470, "author_profile": "https://wordpress.stackexchange.com/users/63470", "pm_score": 3, "selected": false, "text": "<p>Yes, you'll need to implement the walker class for this. </p>\n\n<p>Here is a simple example.</p>\n\n<pre><code...
2014/12/18
[ "https://wordpress.stackexchange.com/questions/172609", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60608/" ]
I have an existing widget area / sidebar. Rather than adding content to it via Appearance ? Widgets in the Dashboard, I want to inject content into the widget area from functions.php. Is there hook that allows this? Thanks :)
Yes, you'll need to implement the walker class for this. Here is a simple example. ``` $defaults = array( 'theme_location' => 'primary', 'container' => 'ul', 'menu_class' => 'nav navbar-nav main-nav', 'walker' => new Primary_Walker_Nav_Menu() ); wp_nav_menu( $defaults ); ``` In th...
172,620
<p>I want to get the IDs of the 2 previous and 2 next articles in a certain category to show them as a "related videos" playlist. I know that there are the functions <code>previous_post_link</code> and <code>next_post_link</code>, which would do the job for me, but I want more than just 1 previous and 1 next link.</p> ...
[ { "answer_id": 172634, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": true, "text": "<p>If you want to query for a large set of posts, but don't need full information for each you can use <code>'fields' =...
2014/12/18
[ "https://wordpress.stackexchange.com/questions/172620", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64986/" ]
I want to get the IDs of the 2 previous and 2 next articles in a certain category to show them as a "related videos" playlist. I know that there are the functions `previous_post_link` and `next_post_link`, which would do the job for me, but I want more than just 1 previous and 1 next link. Imagine the following scenar...
If you want to query for a large set of posts, but don't need full information for each you can use `'fields' => 'ids'`m see [Return Fields Parameter](http://codex.wordpress.org/Class_Reference/WP_Query#Return_Fields_Parameter). In this case, I concur with comment, it might make more sense to simply retrieve adjacent ...
172,645
<p>Being given a taxonomy or term, is is possible to pull any / all post types the taxonomy is attached to?</p> <p>For example, knowing the built in taxonomy <code>category</code> or being given a term in the <code>category</code> taxonomy, is there a function to reverse engineer that <code>category</code> is a taxono...
[ { "answer_id": 172648, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": false, "text": "<p>You can do the reverse with <a href=\"http://codex.wordpress.org/Function_Reference/get_object_taxonomies\"><code>...
2014/12/18
[ "https://wordpress.stackexchange.com/questions/172645", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
Being given a taxonomy or term, is is possible to pull any / all post types the taxonomy is attached to? For example, knowing the built in taxonomy `category` or being given a term in the `category` taxonomy, is there a function to reverse engineer that `category` is a taxonomy of `post` ? **Unneeded Info** I'm work...
If we peek into the global `$wp_taxonomies` variable we see the associated object types. There might be better ways to do this or even core functions, but you could try the following: ``` function wpse_172645_get_post_types_by_taxonomy( $tax = 'category' ) { global $wp_taxonomies; return ( isset( $wp_taxonom...
172,674
<p>Is there a hook that would allow me to email multiple email addresses for the default admin email notifications?</p> <p>I was hoping I could build an array:</p> <pre><code>$adminEmails = array('me1@example.com', 'me2@example.com'); </code></pre> <p>Then have all admin emails (like new user notifications) sent to ...
[ { "answer_id": 172676, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 3, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>update_option( 'admin_email', 'me1@example.com, me2@example.com' );\n</code></pre>...
2014/12/18
[ "https://wordpress.stackexchange.com/questions/172674", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48679/" ]
Is there a hook that would allow me to email multiple email addresses for the default admin email notifications? I was hoping I could build an array: ``` $adminEmails = array('me1@example.com', 'me2@example.com'); ``` Then have all admin emails (like new user notifications) sent to $adminEmails Possible?
Try this: ``` update_option( 'admin_email', 'me1@example.com, me2@example.com' ); ``` Note that the value is a string; open and close quotes only!
172,689
<p>Why exactly does Wordpress 4.0.1 want to upgrade to 4.1 automatically?</p> <p>To be specific, I see in wp_options table, in option with name </p> <p><code>_site_transient_update_core</code>, a serialized array with an update, AND an autoupdate:</p> <blockquote> <p>...O:8:"stdClass":11:{s:8:"response";s:10:"auto...
[ { "answer_id": 172676, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 3, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>update_option( 'admin_email', 'me1@example.com, me2@example.com' );\n</code></pre>...
2014/12/19
[ "https://wordpress.stackexchange.com/questions/172689", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25767/" ]
Why exactly does Wordpress 4.0.1 want to upgrade to 4.1 automatically? To be specific, I see in wp\_options table, in option with name `_site_transient_update_core`, a serialized array with an update, AND an autoupdate: > > ...O:8:"stdClass":11:{s:8:"response";s:10:"autoupdate";s:8:"download";s:57:"<https://downlo...
Try this: ``` update_option( 'admin_email', 'me1@example.com, me2@example.com' ); ``` Note that the value is a string; open and close quotes only!
172,690
<pre><code>// Initialization and Hooks global $wpdb; global $wp_version; global $wpmyfirstplugin_version; global $wpmyfirstplugin_db_version; global $wpmyfirstplugin_table_name; global $wp_version; $wpmyfirstplugin_version = '1.0.1'; $wpmyfirstplugin_db_version = '0.0.1'; $wpmyfirstplugin_table_name = $wpdb-&gt;prefix....
[ { "answer_id": 172693, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": 3, "selected": true, "text": "<p>You are getting this error because 'wpmyfirstplugin_createTable' is called on register_activation_hook. This ho...
2014/12/19
[ "https://wordpress.stackexchange.com/questions/172690", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65022/" ]
``` // Initialization and Hooks global $wpdb; global $wp_version; global $wpmyfirstplugin_version; global $wpmyfirstplugin_db_version; global $wpmyfirstplugin_table_name; global $wp_version; $wpmyfirstplugin_version = '1.0.1'; $wpmyfirstplugin_db_version = '0.0.1'; $wpmyfirstplugin_table_name = $wpdb->prefix.'imart_set...
You are getting this error because 'wpmyfirstplugin\_createTable' is called on register\_activation\_hook. This hook is called when a plugin is activated from dashboard and before declaring any variable. So when this function runs it does not get the table name parameter.
172,700
<p>I've been searching high and low for this but can't find anything that explains how to add custom fields to only the reply form. I've seen and got working custom fields on the comment form, but when a user clicks reply, I want to have a different set of fields. Better still a different set of fields depending on the...
[ { "answer_id": 172702, "author": "Amit Mishra", "author_id": 47962, "author_profile": "https://wordpress.stackexchange.com/users/47962", "pm_score": 1, "selected": false, "text": "<p>By using <code>comment_form( $args, $post_id )</code> you can add extra field in your comment form like t...
2014/12/19
[ "https://wordpress.stackexchange.com/questions/172700", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65027/" ]
I've been searching high and low for this but can't find anything that explains how to add custom fields to only the reply form. I've seen and got working custom fields on the comment form, but when a user clicks reply, I want to have a different set of fields. Better still a different set of fields depending on the re...
By using `comment_form( $args, $post_id )` you can add extra field in your comment form like this ``` $commenter = wp_get_current_commenter(); $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); $fields = array( 'author' => '<p class="comment-form-author">' . '<label f...
172,703
<p>I want a thumbnail of the featured image of the posts as a URL. So I'm using the following code to get a smaller size of the featured image.</p> <pre><code>$post[$i]['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($post[$i]['id'], 'thumbnail')); </code></pre> <p>However all the time it returns the full ...
[ { "answer_id": 172704, "author": "Karun", "author_id": 63470, "author_profile": "https://wordpress.stackexchange.com/users/63470", "pm_score": 2, "selected": false, "text": "<p>You can try using the <code>wp_get_attachment_image_src()</code></p>\n\n<pre><code>$thumb_id = get_post_thumbna...
2014/12/19
[ "https://wordpress.stackexchange.com/questions/172703", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65031/" ]
I want a thumbnail of the featured image of the posts as a URL. So I'm using the following code to get a smaller size of the featured image. ``` $post[$i]['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($post[$i]['id'], 'thumbnail')); ``` However all the time it returns the full size image, I even tried, ...
Hey First add this line into your function.php file ``` add_image_size( 'custom-size', 120, 140 ); ``` Then call custom-size like this ``` <?php $thumb_id = get_post_thumbnail_id( $id ); if ( '' != $thumb_id ) { $thumb_url = wp_get_attachment_image_src( $thumb_id, 'custom-size...
172,714
<p>For some reason i need the actual address of current page in my plugin , but after searching i can not find any answer on how i can get the real address of current page.<br> I tested many functions for example <code>url_to_postid</code>.<br> But this function returns 0 in categories , archives and many other links ,...
[ { "answer_id": 172704, "author": "Karun", "author_id": 63470, "author_profile": "https://wordpress.stackexchange.com/users/63470", "pm_score": 2, "selected": false, "text": "<p>You can try using the <code>wp_get_attachment_image_src()</code></p>\n\n<pre><code>$thumb_id = get_post_thumbna...
2014/12/19
[ "https://wordpress.stackexchange.com/questions/172714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59316/" ]
For some reason i need the actual address of current page in my plugin , but after searching i can not find any answer on how i can get the real address of current page. I tested many functions for example `url_to_postid`. But this function returns 0 in categories , archives and many other links , and this only w...
Hey First add this line into your function.php file ``` add_image_size( 'custom-size', 120, 140 ); ``` Then call custom-size like this ``` <?php $thumb_id = get_post_thumbnail_id( $id ); if ( '' != $thumb_id ) { $thumb_url = wp_get_attachment_image_src( $thumb_id, 'custom-size...
172,727
<p>I want to have a custom post type, named <code>event</code>, listed with normal posts in the category pages.</p> <p>I have managed to add categories easily to the custom post type with this:</p> <pre><code>add_action('init', 'add_category_boxes'); add_action('plugins_loaded','add_category_boxes'); function add_cat...
[ { "answer_id": 172864, "author": "jay.jivani", "author_id": 65082, "author_profile": "https://wordpress.stackexchange.com/users/65082", "pm_score": 0, "selected": false, "text": "<p>For creating taxonomy like category &amp; tags for custom post type use <code>register_taxonomy</code> wor...
2014/12/19
[ "https://wordpress.stackexchange.com/questions/172727", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21333/" ]
I want to have a custom post type, named `event`, listed with normal posts in the category pages. I have managed to add categories easily to the custom post type with this: ``` add_action('init', 'add_category_boxes'); add_action('plugins_loaded','add_category_boxes'); function add_category_boxes() { register_taxon...
You have one or two problems here * `is_category()` should be object of `$query` in your example code * `get_query_var('post_type')` will always return false on a category page AFAIK, so that code is totally unnecessary * Just a tip, when using `pre_get_posts` with any type of archive, also check for non admin pages a...
172,735
<p>I want to display a number of articles in a certain category which is hooked to a menu item. It should look like Bootstrap's "badge" component. Now I've got:</p> <p><img src="https://i.stack.imgur.com/TtHZ4.png" alt="Current - without "></p> <p>and what I want to achieve:</p> <p><img src="https://i.stack.imgur.co...
[ { "answer_id": 172742, "author": "Amit Mishra", "author_id": 47962, "author_profile": "https://wordpress.stackexchange.com/users/47962", "pm_score": 0, "selected": false, "text": "<p>Hey by using the code snippet you can get the number of article within the category</p>\n\n<pre><code>$po...
2014/12/19
[ "https://wordpress.stackexchange.com/questions/172735", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65044/" ]
I want to display a number of articles in a certain category which is hooked to a menu item. It should look like Bootstrap's "badge" component. Now I've got: ![Current - without ](https://i.stack.imgur.com/TtHZ4.png) and what I want to achieve: ![What I want](https://i.stack.imgur.com/B2ypW.png) Do I have to modify...
I think it would be useful to create a custom walker for your menu. In the following code example I made use of the Menu Item Object. You can take a look at the object output [here](http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items). An object type is specified for every menu item. So I just compare ...
172,754
<p>I need to add a class to the WordPress search widget. How would I go about doing so? I'm calling it from the admin side, as in dragging and dropping it into the sidebar at the widgets page of the admin section. I'm not calling it using get_search_form. I want to do so by using the functions.php file, not jQuery or a...
[ { "answer_id": 172755, "author": "Amit Mishra", "author_id": 47962, "author_profile": "https://wordpress.stackexchange.com/users/47962", "pm_score": 2, "selected": false, "text": "<p>Hey you can add class in before_widget something like this</p>\n\n<pre><code>if ( function_exists('regist...
2014/12/19
[ "https://wordpress.stackexchange.com/questions/172754", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51409/" ]
I need to add a class to the WordPress search widget. How would I go about doing so? I'm calling it from the admin side, as in dragging and dropping it into the sidebar at the widgets page of the admin section. I'm not calling it using get\_search\_form. I want to do so by using the functions.php file, not jQuery or ad...
Alright, so I managed to pull it off thanks to [@toscho](https://wordpress.stackexchange.com/users/73/toscho) who provided me with this link: [Add class to before\_widget for all widgets with a dropdown and a counter](https://wordpress.stackexchange.com/questions/108400/add-class-to-before-widget-for-all-widgets-with-a...
172,766
<p>I can't get the Featured Image metabox to show up on the edit page for the default <code>post</code> and <code>page</code> post types.</p> <p>Though as opposed to <a href="https://wordpress.stackexchange.com/questions/92455/featured-image-metabox-not-showing-up">this question</a>, it <em>does</em> work for the cust...
[ { "answer_id": 172785, "author": "propz", "author_id": 64941, "author_profile": "https://wordpress.stackexchange.com/users/64941", "pm_score": 2, "selected": false, "text": "<ol>\n<li><p>You don't need to pass an array to the function if you want Post Thumbnails everywhere. Just pass the...
2014/12/19
[ "https://wordpress.stackexchange.com/questions/172766", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63414/" ]
I can't get the Featured Image metabox to show up on the edit page for the default `post` and `page` post types. Though as opposed to [this question](https://wordpress.stackexchange.com/questions/92455/featured-image-metabox-not-showing-up), it *does* work for the custom post type I've created using a plugin. It just ...
By default post types "post" and "page" do have support for featured image meta box. You don't need to add some thing in function.php for that. This might be happening due to some plugin confliction. I would suggest try deactivating your plugins one by one and check if it gets back.
172,771
<pre><code>// MOVE REVISIONS METABOX TO BOTTOM OF EDIT-FORM.PHP $post_types = get_post_types(); add_action('do_meta_boxes', 'batteryboys_reorder_meta_boxes'); function batteryboys_reorder_meta_boxes(){ remove_meta_box( 'revisionsdiv', $post_types, 'normal' ); add_meta_box('revisionsdiv', __('Revisions'), 'post_...
[ { "answer_id": 172777, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p><code>$post_types</code> is undefined inside your function, <code>add_meta_box</code> checks if the value is null ...
2014/12/19
[ "https://wordpress.stackexchange.com/questions/172771", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43351/" ]
``` // MOVE REVISIONS METABOX TO BOTTOM OF EDIT-FORM.PHP $post_types = get_post_types(); add_action('do_meta_boxes', 'batteryboys_reorder_meta_boxes'); function batteryboys_reorder_meta_boxes(){ remove_meta_box( 'revisionsdiv', $post_types, 'normal' ); add_meta_box('revisionsdiv', __('Revisions'), 'post_revisio...
As @Milo pointed out, when you use code in OP `$post_types` is undefined inside the function, so WordPress will act just like it was not there at all. However, that means you are using an undefined variable, and if [turn `WP_DEBUG` on](http://codex.wordpress.org/Debugging_in_WordPress) you'll see a warning, and so you...
172,814
<p>I am using Wordpress Multisite Network and i am having problems regarding masters to its subsite. I am not able to see the widgets or Menus which were created on Main website to its Sub-site. When i am going to check in the Database whole tables are different of every subsite. So is there any way to Sync Masters lik...
[ { "answer_id": 172848, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 0, "selected": false, "text": "<p>On default is each site in the network a single site in the context, menu, settings, widgets. But you can sync ab...
2014/12/20
[ "https://wordpress.stackexchange.com/questions/172814", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54837/" ]
I am using Wordpress Multisite Network and i am having problems regarding masters to its subsite. I am not able to see the widgets or Menus which were created on Main website to its Sub-site. When i am going to check in the Database whole tables are different of every subsite. So is there any way to Sync Masters like c...
That's an old question, if someone like me landed on this page and want some-sort of custom solution for WORDPRESS MULTISITE MENU sharing across all network sites, Not only menu you can use the same method to share anything other then widgets across all the network sites. here is the solution : Edit your Header.php ...
172,816
<p>If I have "pretty" permalinks enabled my code will work for static pages (will work if page is set as "home page" or "normal page" ). But my code breaks if I use "default permalink" structure. </p> <p>I have this so far (working nice with "pretty permalinks" but breaks with "ugly permalinks"):</p> <pre><code>/*Dec...
[ { "answer_id": 172818, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 5, "selected": true, "text": "<h2>EDIT - WORDPRESS 4.4.1 BUG</h2>\n\n<p>Please take note that there is a bug in WordPress 4.4.1 (<em>I'm ...
2014/12/20
[ "https://wordpress.stackexchange.com/questions/172816", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20941/" ]
If I have "pretty" permalinks enabled my code will work for static pages (will work if page is set as "home page" or "normal page" ). But my code breaks if I use "default permalink" structure. I have this so far (working nice with "pretty permalinks" but breaks with "ugly permalinks"): ``` /*Declared above the loop*...
EDIT - WORDPRESS 4.4.1 BUG -------------------------- Please take note that there is a bug in WordPress 4.4.1 (*I'm not sure if this bug also influence WordPress 4.4, but according to the bug report, it does not*) which fails pagination when setting a page as static front page. Be sure to check out the bug report ([*t...
172,849
<p>I can not comment on an exciting question because my reputation is too low and when I reply inside that exciting topic it will get deleted because it's not a solution but another question so I start a brand new (same) question. :S</p> <p>This is the question I'm talking about. <a href="https://wordpress.stackexchan...
[ { "answer_id": 172818, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 5, "selected": true, "text": "<h2>EDIT - WORDPRESS 4.4.1 BUG</h2>\n\n<p>Please take note that there is a bug in WordPress 4.4.1 (<em>I'm ...
2014/12/20
[ "https://wordpress.stackexchange.com/questions/172849", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59031/" ]
I can not comment on an exciting question because my reputation is too low and when I reply inside that exciting topic it will get deleted because it's not a solution but another question so I start a brand new (same) question. :S This is the question I'm talking about. [Add an alignment option for images](https://wor...
EDIT - WORDPRESS 4.4.1 BUG -------------------------- Please take note that there is a bug in WordPress 4.4.1 (*I'm not sure if this bug also influence WordPress 4.4, but according to the bug report, it does not*) which fails pagination when setting a page as static front page. Be sure to check out the bug report ([*t...
172,851
<p>I would like to create a very simple search tool that works independently of the regular search.</p> <p>The concept is simple, search all titles of a particular post type for an EXACT match, if it finds a match go straight to the post. If not, return no match found.</p> <p>I'm sure this is incredibly simple but I'...
[ { "answer_id": 172885, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>It is actually pretty annoying to bend <code>WP_Query</code> for it. However there is convenient <a href=\"http://q...
2014/12/20
[ "https://wordpress.stackexchange.com/questions/172851", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64488/" ]
I would like to create a very simple search tool that works independently of the regular search. The concept is simple, search all titles of a particular post type for an EXACT match, if it finds a match go straight to the post. If not, return no match found. I'm sure this is incredibly simple but I'm struggling. I'v...
That sent me in the right direction. Here is what I have came up with. I decided to create a shortcode so I can drop this anywhere needed. Using the get\_page\_by\_title() also allowed me to find posts even if their post type was hidden from the traditional search. ``` function esm_search($atts) { extract(shor...
172,855
<p>I was wondering if there is a way to display the page content and a list of posts from a specific category on the same page in my wordpress blog using a template.</p> <p>I have a child theme set up, but don't know anything about the wordpress page structure. All of my attempts to achieve this have been unsuccessful...
[ { "answer_id": 172859, "author": "tfrommen", "author_id": 27722, "author_profile": "https://wordpress.stackexchange.com/users/27722", "pm_score": 0, "selected": false, "text": "<p>This question is pretty broad, so my answer is as well.</p>\n\n<p>Set up a new page template. Create a new p...
2014/12/21
[ "https://wordpress.stackexchange.com/questions/172855", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I was wondering if there is a way to display the page content and a list of posts from a specific category on the same page in my wordpress blog using a template. I have a child theme set up, but don't know anything about the wordpress page structure. All of my attempts to achieve this have been unsuccessful so-far. ...
php file add the following code snippet ``` <?php get_header(); ?> <?php while ( have_posts() ) : the_post(); ?> <?php the_title( '<h1>', '</h1>' ); ?> <?php the_content(); ?> <?php endwhile; // end of the loop. ?> <?php $post = array( 'post_type' => 'post', 'order' => 'ASC', '...
172,882
<p>I have a question about website layout with and without wp widges in sidebar. Here is the code i have for my registered sidebar.</p> <pre><code>&lt;?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(products) ) : endif; ?&gt; </code></pre> <p>And this is the code i have in functions.php</p> <pre><c...
[ { "answer_id": 172884, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>You can use <a href=\"http://queryposts.com/function/is_active_sidebar/\" rel=\"nofollow\"><code>is_active_sidebar(...
2014/12/21
[ "https://wordpress.stackexchange.com/questions/172882", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23036/" ]
I have a question about website layout with and without wp widges in sidebar. Here is the code i have for my registered sidebar. ``` <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(products) ) : endif; ?> ``` And this is the code i have in functions.php ``` if (function_exists('register_sidebar')...
You can use [`is_active_sidebar()`](http://queryposts.com/function/is_active_sidebar/) as a condition to enqueue your styles. It does precisely that — tells you if it has any widgets assigned. PS stop `function_exists()` madness :) that is completely pointless check in modern WordPress.
172,939
<p>I have a function that adds items to the WordPress toolbar. For example:</p> <pre><code>$args2 = array( 'id' =&gt; 'conversations_unread', 'title' =&gt; $visitor['conversations_unread'] . ' &amp;nbsp ', 'href' =&gt; XenForo_Application::get('options')-&gt;boardUrl . '/conversations' ); </code></pre>...
[ { "answer_id": 172940, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 5, "selected": true, "text": "<h2>Full example</h2>\n<p>A quick (mu-)plugin as example:</p>\n<pre><code>&lt;?php\n/** Plugin Name: Add Admin Bar Ico...
2014/12/22
[ "https://wordpress.stackexchange.com/questions/172939", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47326/" ]
I have a function that adds items to the WordPress toolbar. For example: ``` $args2 = array( 'id' => 'conversations_unread', 'title' => $visitor['conversations_unread'] . ' &nbsp ', 'href' => XenForo_Application::get('options')->boardUrl . '/conversations' ); ``` How do I get an icon to the left of t...
Full example ------------ A quick (mu-)plugin as example: ``` <?php /** Plugin Name: Add Admin Bar Icon */ add_action( 'admin_bar_menu', function( \WP_Admin_Bar $bar ) { $bar->add_menu( array( 'id' => 'wpse', 'parent' => null, 'group' => null, 'title' => __( 'Example', 'some-...
172,945
<p>I am working on a widget for my theme. If I do a</p> <pre><code>print_r($insance) </code></pre> <p>in the form function, the instance array is populated with the correct data. I have checked the database and the correct information is there in the options table for my widget. </p> <p>My problem is that, if I do ...
[ { "answer_id": 173007, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": true, "text": "<p>Your widget really has a lot of issues and completely breaks my layout on my back-end widget page. I sug...
2014/12/22
[ "https://wordpress.stackexchange.com/questions/172945", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14761/" ]
I am working on a widget for my theme. If I do a ``` print_r($insance) ``` in the form function, the instance array is populated with the correct data. I have checked the database and the correct information is there in the options table for my widget. My problem is that, if I do a ``` print_r($instance) ``` ...
Your widget really has a lot of issues and completely breaks my layout on my back-end widget page. I suggest that you start at the [Widget API](http://codex.wordpress.org/Widgets_API) to learn the proper way how to code a widget Here is a couple of issues I have picked up: * Reputable sources should not be suggesting...
172,958
<p>I have a permalink issue. For your information, there are a few different categories within a website and there are many posts in a single category.</p> <p>My permalink setting is:</p> <p>Custom Stucture: <code>/%category%/%postname%/</code></p> <p>Category Base: .</p> <p>After this setting saved, my url will be...
[ { "answer_id": 172961, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 5, "selected": true, "text": "<p>That is totally normal behaviour. If you want to remove category base you will need to write some custom rewri...
2014/12/22
[ "https://wordpress.stackexchange.com/questions/172958", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23036/" ]
I have a permalink issue. For your information, there are a few different categories within a website and there are many posts in a single category. My permalink setting is: Custom Stucture: `/%category%/%postname%/` Category Base: . After this setting saved, my url will be > > www.mydomain.com/category-slug-nam...
That is totally normal behaviour. If you want to remove category base you will need to write some custom rewrite rules, not simple rules I must say. From my point of view, removing category base requires a extra job in each request that is worthless because it doesn't provide any advantage for SEO or for better site na...
172,966
<p>I am trying to enable <code>304 If Modified Since HTTP header</code> in my WordPress site. After doing lot of Googling I find out a site where the author said to put the following line at the very end of wordpress <code>wp-config.php</code> file. Here is the line of code:</p> <pre><code>header("Last-Modified: " . t...
[ { "answer_id": 172968, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 3, "selected": true, "text": "<p><code>the_modified_date()</code> is a template tag that must used inside the loop, that is why it is not wokri...
2014/12/22
[ "https://wordpress.stackexchange.com/questions/172966", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50584/" ]
I am trying to enable `304 If Modified Since HTTP header` in my WordPress site. After doing lot of Googling I find out a site where the author said to put the following line at the very end of wordpress `wp-config.php` file. Here is the line of code: ``` header("Last-Modified: " . the_modified_date()); ``` Now the a...
`the_modified_date()` is a template tag that must used inside the loop, that is why it is not wokring for you. WordPress provide a action and filter hook to include or modify HTTP headers: * [`send_headers` action](http://codex.wordpress.org/Plugin_API/Action_Reference/send_headers) * [`wp_headers` filter](https://de...
172,984
<p>Is there a way to make a conditional tag that tests if it is <code>search-no-results</code> page?</p> <p>I know that there is a function to check if <a href="http://codex.wordpress.org/Function_Reference/is_search" rel="nofollow"><code>is_search()</code></a> page:</p> <pre><code>if(is_search()){ echo "search p...
[ { "answer_id": 172985, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 4, "selected": true, "text": "<p>There is no conditional tag for no results on a search page, but you can create yourself one.</p>\n\n<p>...
2014/12/22
[ "https://wordpress.stackexchange.com/questions/172984", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39259/" ]
Is there a way to make a conditional tag that tests if it is `search-no-results` page? I know that there is a function to check if [`is_search()`](http://codex.wordpress.org/Function_Reference/is_search) page: ``` if(is_search()){ echo "search page"; } ``` But I didn't found a way to check for search-no-results...
There is no conditional tag for no results on a search page, but you can create yourself one. You basically just have to check the value of `$wp_query->found_posts`, if it is `0`, returns `false`, any other value, returns `true` ``` function is_search_has_results() { return 0 != $GLOBALS['wp_query']->found_posts;...
173,029
<p>I am working on a plugin and the plugin currently works great on the admin section but I'm trying to extend the functionality to the front end and using a shortcode to use the same functions. I have a form that gets displayed currently with the following code:</p> <pre><code>function display_sheet_form($f=array()) ...
[ { "answer_id": 330304, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>The <code>add_shortcode()</code> function's second parameter should be a function that outputs text/co...
2014/12/23
[ "https://wordpress.stackexchange.com/questions/173029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13472/" ]
I am working on a plugin and the plugin currently works great on the admin section but I'm trying to extend the functionality to the front end and using a shortcode to use the same functions. I have a form that gets displayed currently with the following code: ``` function display_sheet_form($f=array()) { $count ...
Rick's answer is incorrect, as the documentation for [add\_shortcode](https://developer.wordpress.org/reference/functions/add_shortcode/) specifies that "the function called by the shortcode should *never* produce an output of any kind". Instead, you should return the text that you want the shortcode to output. So, try...
173,078
<p>I am trying to insert the user firstname and last name into the database whilst processing a woocommerce order. I have managed to get two empty fields into the database where I need them however i am struggling to get the users first name and last name to post. Below is the code i have so far, would someone be able ...
[ { "answer_id": 173074, "author": "Fatih SARI", "author_id": 62927, "author_profile": "https://wordpress.stackexchange.com/users/62927", "pm_score": 0, "selected": false, "text": "<p>This is not interest in Wordpress. You can create different different script.\nIt must has database and in...
2014/12/23
[ "https://wordpress.stackexchange.com/questions/173078", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64567/" ]
I am trying to insert the user firstname and last name into the database whilst processing a woocommerce order. I have managed to get two empty fields into the database where I need them however i am struggling to get the users first name and last name to post. Below is the code i have so far, would someone be able to ...
The the easiest way to create shortlink is by using [Jetpack Plugin](https://wordpress.org/plugins/jetpack/) developed by Automatic guys. This plugin comes with a lot of modules one of them is `wp.me` shortlink, which will give you the ability to create shortlink for any page/post/custom post in your site. it will b...
173,106
<p>I'm trying to enqueue JavaScript files using wp_enqueue_script(), but it isn't working at all. Here is my code:</p> <pre><code>function load_css_js() { wp_enqueue_style('gdgt-base', get_template_directory_uri() . '/css/gdgt-base.css'); wp_enqueue_style('gdgt-icon', get_template_directory_uri() . '/icons/css...
[ { "answer_id": 173110, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 4, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_style\" rel=\"noreferrer\"><code>wp_enq...
2014/12/23
[ "https://wordpress.stackexchange.com/questions/173106", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63232/" ]
I'm trying to enqueue JavaScript files using wp\_enqueue\_script(), but it isn't working at all. Here is my code: ``` function load_css_js() { wp_enqueue_style('gdgt-base', get_template_directory_uri() . '/css/gdgt-base.css'); wp_enqueue_style('gdgt-icon', get_template_directory_uri() . '/icons/css/gdgt.css', ...
[`wp_enqueue_style`](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) and [`wp_enqueue_script`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) accepts many parameters and it's very important to use them in correct order otherwise these functions will fail. Here are complete set of para...
173,121
<p>I'm trying to give access to an user with the role Editor to this plugin settings page: <a href="https://wordpress.org/plugins/commenter-data/" rel="nofollow">https://wordpress.org/plugins/commenter-data/</a></p> <p>In the code of this plugin on line 31 of commenter.php there is this function: </p> <pre><code>func...
[ { "answer_id": 180375, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://wordpress.org/support/topic/header-link-httpgmpgorgxfn11\" rel=\"nofollow\">As asked on th...
2014/12/24
[ "https://wordpress.stackexchange.com/questions/173121", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/30592/" ]
I'm trying to give access to an user with the role Editor to this plugin settings page: <https://wordpress.org/plugins/commenter-data/> In the code of this plugin on line 31 of commenter.php there is this function: ``` function cd_setting_page(){ add_options_page( 'Commenter data Settings', 'Commenter data Setti...
This profile enables your site to use the **FOAF** semantic insertions for richer metadata on your site. FOAF goes for *Friend Of A Friend* and aims to interconnect in "knowledge nodes" all the personal interconnections. Despite it started as a Person to Person oriented RDF vocabulary, it went beyond and included some ...
173,159
<p>I registered a custom post type ("movie") with tags and categories. Now, I'm able to filter and search for the custom post with these tags and categories, so I know they're present and working, but they're not showing up on the custom posts.</p> <p>This is the code for the meta data to show up.</p> <pre><code>&lt;...
[ { "answer_id": 173160, "author": "Karun", "author_id": 63470, "author_profile": "https://wordpress.stackexchange.com/users/63470", "pm_score": 3, "selected": true, "text": "<p>Your argument for <code>is_singular()</code> is wrong </p>\n\n<p>It should be an array</p>\n\n<pre><code>is_sing...
2014/12/24
[ "https://wordpress.stackexchange.com/questions/173159", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65210/" ]
I registered a custom post type ("movie") with tags and categories. Now, I'm able to filter and search for the custom post with these tags and categories, so I know they're present and working, but they're not showing up on the custom posts. This is the code for the meta data to show up. ``` <?php if( !myThemes::get(...
Your argument for `is_singular()` is wrong It should be an array ``` is_singular(array('post','movie')) ``` You can read more about the argument passed from this [link here](http://codex.wordpress.org/Function_Reference/is_singular)
173,166
<p>I am new to WordPress development, hope this is not a too stupid question.</p> <p>I want to Move my "Camp" Page(that appear Under Pages -> Camp) into Dashboard Main menu,</p> <p>if its not possible to move page then tell me how to create shortcut in main menu</p> <p>see the below screenshot<img src="https://i.sta...
[ { "answer_id": 173201, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>If you look at the browser’s address bar on that page’s edit screen, you see something like this:</p>\n\n<pre><code>w...
2014/12/24
[ "https://wordpress.stackexchange.com/questions/173166", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64198/" ]
I am new to WordPress development, hope this is not a too stupid question. I want to Move my "Camp" Page(that appear Under Pages -> Camp) into Dashboard Main menu, if its not possible to move page then tell me how to create shortcut in main menu see the below screenshot![enter image description here](https://i.stack...
I have used > > add\_menu\_page > > > function to achieve the solution ``` add_action( 'admin_menu', 'register_my_custom_menu_page' ); function register_my_custom_menu_page() { add_menu_page( 'camp', 'Camp', 'edit_pages', 'post.php?post=128&action=edit', '', ...
173,178
<p>I've create a form by metabox and save data in custom table</p> <p>my table is:</p> <pre><code>$table_name = $wpdb-&gt;prefix . 'aacv'; $sql = "CREATE TABLE $table_name ( id int(11) NOT NULL AUTO_INCREMENT, user_id int(20) Not Null, name varchar(255) collate utf8_unicode_ci NOT NULL, lastname varch...
[ { "answer_id": 173201, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>If you look at the browser’s address bar on that page’s edit screen, you see something like this:</p>\n\n<pre><code>w...
2014/12/24
[ "https://wordpress.stackexchange.com/questions/173178", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65216/" ]
I've create a form by metabox and save data in custom table my table is: ``` $table_name = $wpdb->prefix . 'aacv'; $sql = "CREATE TABLE $table_name ( id int(11) NOT NULL AUTO_INCREMENT, user_id int(20) Not Null, name varchar(255) collate utf8_unicode_ci NOT NULL, lastname varchar(255) collate utf8_uni...
I have used > > add\_menu\_page > > > function to achieve the solution ``` add_action( 'admin_menu', 'register_my_custom_menu_page' ); function register_my_custom_menu_page() { add_menu_page( 'camp', 'Camp', 'edit_pages', 'post.php?post=128&action=edit', '', ...
173,184
<p>The following code hides a meta box when certain categories are selected using jquery, in post editor. It works with <code>post</code> as the custom post type. I need it to work with a custom post type called <code>events</code>. The <code>event</code> type uses a custom taxonomy called event categories, I want to ...
[ { "answer_id": 173201, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>If you look at the browser’s address bar on that page’s edit screen, you see something like this:</p>\n\n<pre><code>w...
2014/12/24
[ "https://wordpress.stackexchange.com/questions/173184", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
The following code hides a meta box when certain categories are selected using jquery, in post editor. It works with `post` as the custom post type. I need it to work with a custom post type called `events`. The `event` type uses a custom taxonomy called event categories, I want to use the ids in these categories with ...
I have used > > add\_menu\_page > > > function to achieve the solution ``` add_action( 'admin_menu', 'register_my_custom_menu_page' ); function register_my_custom_menu_page() { add_menu_page( 'camp', 'Camp', 'edit_pages', 'post.php?post=128&action=edit', '', ...
173,197
<p>I have a WordPress form plugin and I use <a href="http://codex.wordpress.org/Function_Reference/media_handle_upload"><code>media_handle_upload</code></a> to upload the files and get there ids directly and attached its ids to the post as a meta date, I used the following to did that:</p> <p>The HTML of the form fiel...
[ { "answer_id": 173236, "author": "Shady M Rasmy", "author_id": 17025, "author_profile": "https://wordpress.stackexchange.com/users/17025", "pm_score": 5, "selected": true, "text": "<p>here\nif you use custom template past this in the begining</p>\n\n<pre><code>&lt;?php\n if( 'POST' == $_...
2014/12/25
[ "https://wordpress.stackexchange.com/questions/173197", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64134/" ]
I have a WordPress form plugin and I use [`media_handle_upload`](http://codex.wordpress.org/Function_Reference/media_handle_upload) to upload the files and get there ids directly and attached its ids to the post as a meta date, I used the following to did that: The HTML of the form field is: ``` <input type="file" na...
here if you use custom template past this in the begining ``` <?php if( 'POST' == $_SERVER['REQUEST_METHOD'] ) { if ( $_FILES ) { $files = $_FILES["my_file_upload"]; foreach ($files['name'] as $key => $value) { if ($files['name'][$key]) { $file = array( ...
173,203
<p>Right now about 25% of the entries in my access log (which do not show resource like css, images, etc) are requests to wp-cron.php. I assume there is some process event that got "stuck" and keep firing but how can I find which one?</p> <p>It is a live server there the amount of hacking I can do at the code to find ...
[ { "answer_id": 173227, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>I would create a simple plugin that spits the data out into a private admin page, you basically want to use:</p>\n...
2014/12/25
[ "https://wordpress.stackexchange.com/questions/173203", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23970/" ]
Right now about 25% of the entries in my access log (which do not show resource like css, images, etc) are requests to wp-cron.php. I assume there is some process event that got "stuck" and keep firing but how can I find which one? It is a live server there the amount of hacking I can do at the code to find the proble...
I would create a simple plugin that spits the data out into a private admin page, you basically want to use: ``` $cron = _get_cron_array(); $schedules = wp_get_schedules(); $tranny = get_transient('doing_cron'); //var_dump or loop over these ``` There are several plugins that do this that style the output to make it...
173,253
<p>I got below code in TwentyFourteen theme's function.php file.</p> <pre><code>register_nav_menus( array( 'primary' =&gt; __( 'Top primary menu', 'twentyfourteen' ), 'secondary' =&gt; __( 'Secondary menu in left sidebar', 'twentyfourteen' ), ) ); </code></pre> <p>I would like to know about <cod...
[ { "answer_id": 173227, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>I would create a simple plugin that spits the data out into a private admin page, you basically want to use:</p>\n...
2014/12/26
[ "https://wordpress.stackexchange.com/questions/173253", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65189/" ]
I got below code in TwentyFourteen theme's function.php file. ``` register_nav_menus( array( 'primary' => __( 'Top primary menu', 'twentyfourteen' ), 'secondary' => __( 'Secondary menu in left sidebar', 'twentyfourteen' ), ) ); ``` I would like to know about `twentyfourteen`. I know this is des...
I would create a simple plugin that spits the data out into a private admin page, you basically want to use: ``` $cron = _get_cron_array(); $schedules = wp_get_schedules(); $tranny = get_transient('doing_cron'); //var_dump or loop over these ``` There are several plugins that do this that style the output to make it...
173,269
<p>by default Wordpress shows blog posts one beneath the other showing short text and, if available, an image. The question is - is it possible to change that? I would like to have a grid consisting of 3 columns and 4 rows per page, and one item (blog post) in a grid would be a featured photo. Is it possible to adapt W...
[ { "answer_id": 173270, "author": "vlood", "author_id": 733, "author_profile": "https://wordpress.stackexchange.com/users/733", "pm_score": -1, "selected": false, "text": "<p>Yep, it's all a matter of selecting the right theme and setting your posts per page to 12 (Settings -> Reading).</...
2014/12/26
[ "https://wordpress.stackexchange.com/questions/173269", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64494/" ]
by default Wordpress shows blog posts one beneath the other showing short text and, if available, an image. The question is - is it possible to change that? I would like to have a grid consisting of 3 columns and 4 rows per page, and one item (blog post) in a grid would be a featured photo. Is it possible to adapt Word...
I use the masonry way at the end of my css; ``` /* Masonry Custom CSS for the Grid Style Blog */ /* Masonry container */ body.blog div#content, body.archive div#content { -moz-column-count: 3; -webkit-column-count: 3; column-count: 3; -moz-column-gap: 1em; -webkit-column-gap: 1em; column-gap: 1em; max-width: 100%; ma...
173,271
<p>I have a pretty basic question. It may be very noob question, but it is bothering me a lot. In my theme I've added a custom image size like this:</p> <pre><code>function img_update() { if ( function_exists( 'add_image_size' ) ) { add_image_size( 'blog_feat_img', 720 ); add_image_size( 'latest_po...
[ { "answer_id": 173279, "author": "vlood", "author_id": 733, "author_profile": "https://wordpress.stackexchange.com/users/733", "pm_score": 0, "selected": false, "text": "<p>Use '9999' as a height limit for the add_image_size function. Thus, you will have your ratio saved without cropping...
2014/12/26
[ "https://wordpress.stackexchange.com/questions/173271", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50584/" ]
I have a pretty basic question. It may be very noob question, but it is bothering me a lot. In my theme I've added a custom image size like this: ``` function img_update() { if ( function_exists( 'add_image_size' ) ) { add_image_size( 'blog_feat_img', 720 ); add_image_size( 'latest_posts_widget_fea...
At last I've fixed the issue. In my parent theme, the dev have used the following code ``` if ( ! isset( $content_width ) ) { $content_width = 650; } ``` which means if the value of `$content_width` has not set up yet then set it to 650. Now in my chield theme at the time of overwriting and mentioning image typ...
173,274
<p>I'm trying to create a WordPress site that integrates with a very specific CRM in a remote server. The CRM holds a number of entries that should be displayed on the site, but if possible I'd like to avoid exporting and importing them into WordPress.</p> <p>Instead, the WordPress site must be able to take in a custo...
[ { "answer_id": 173275, "author": "vlood", "author_id": 733, "author_profile": "https://wordpress.stackexchange.com/users/733", "pm_score": 0, "selected": false, "text": "<p>You can create a parent page with the slug \"property\" and all remote pages to be children of it with a slug being...
2014/12/26
[ "https://wordpress.stackexchange.com/questions/173274", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65260/" ]
I'm trying to create a WordPress site that integrates with a very specific CRM in a remote server. The CRM holds a number of entries that should be displayed on the site, but if possible I'd like to avoid exporting and importing them into WordPress. Instead, the WordPress site must be able to take in a custom permalin...
I think your problem has several solutions. If you don't want to have one entry in WP database for each remote item, a possible solution could be to have a page with `property` slug and add a rewrite rule to get the ID number: ``` add_action( 'init', 'cyb_property_rewrite_rule' ); function cyb_property_rewrite_rule() ...
173,285
<p>How to automatically create custom field on post draft or publish with one of several offered values? For example I wish to create custom field named "random_color" with one of potential values: "white", "green", "blue"...</p> <p>Any of values is acceptable, so how to create function which will create post custom f...
[ { "answer_id": 173286, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://queryposts.com/function/wp_transition_post_status/\" rel=\"nofollow\"><code>wp_transition_post_sta...
2014/12/26
[ "https://wordpress.stackexchange.com/questions/173285", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25053/" ]
How to automatically create custom field on post draft or publish with one of several offered values? For example I wish to create custom field named "random\_color" with one of potential values: "white", "green", "blue"... Any of values is acceptable, so how to create function which will create post custom field with...
Add an array and [choose one for the value](http://php.net/manual/en/function.array-rand.php). ``` add_action('draft_post', 'add_custom_field'); function add_custom_field($post_ID) { global $wpdb; if(!wp_is_post_revision($post_ID)) { $colors = array('white', 'green', 'blue'); add_post_meta($p...
173,293
<p>I have created custom post type called </p> <blockquote> <p>natural food</p> </blockquote> <p>In my page-natural-food.php</p> <pre><code>&lt;div class="main container"&gt; &lt;div class="content left"&gt; &lt;?php $type = 'naturalfoods'; $paged = (get_query_v...
[ { "answer_id": 173297, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 1, "selected": true, "text": "<p>Change <code>$my_query</code> to <code>$wp_query</code>.<br>\nIn <code>my_simone_paging_nav()</code>, add the ...
2014/12/26
[ "https://wordpress.stackexchange.com/questions/173293", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64198/" ]
I have created custom post type called > > natural food > > > In my page-natural-food.php ``` <div class="main container"> <div class="content left"> <?php $type = 'naturalfoods'; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $arg...
Change `$my_query` to `$wp_query`. In `my_simone_paging_nav()`, add the global `$wp_query` so that `get_query_var` can find `paged`.
173,304
<p>I use this code to show post tag(s) on single.php template:</p> <pre><code>&lt;?php the_tags('&lt;div&gt;Tagged with:&lt;br&gt; ',' | ','&lt;/div&gt;');?&gt; </code></pre> <p>I wish to display post tags on attachment page too, but code above shows nothing on attachment (image.php) template.</p> <p>How to display ...
[ { "answer_id": 173305, "author": "vlood", "author_id": 733, "author_profile": "https://wordpress.stackexchange.com/users/733", "pm_score": 0, "selected": false, "text": "<p>Attachments are a separate post type in WordPress, so on theory if you want to specify tags for each uploaded file,...
2014/12/26
[ "https://wordpress.stackexchange.com/questions/173304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25053/" ]
I use this code to show post tag(s) on single.php template: ``` <?php the_tags('<div>Tagged with:<br> ',' | ','</div>');?> ``` I wish to display post tags on attachment page too, but code above shows nothing on attachment (image.php) template. How to display parent post tag(s) on attachment page (specially on attac...
This should work to get the parent's tags. ``` <?php global $wp_query; $attachment_id = $wp_query->post->ID; $parent_id = get_post_field('post_parent', $attachment_id); $parent_tags = wp_get_post_tags($parent_id); $tag_count = count($parent_tags); // Counting the tags to find know the last one so there is no pipe $i ...
173,324
<p>We suppose that a category has 1000 posts, we can use the following code to show 10 posts per page and the wp pagenavi would present 100 pages with links of above 1000 posts. </p> <pre><code>&lt;?php query_posts($query_string."&amp;showposts=10&amp;orderby=date&amp;order=ASC") ?&gt; </code></pre> <p>Is there any w...
[ { "answer_id": 173326, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": -1, "selected": false, "text": "<p>Actually what you need to do is set <code>max_num_pages</code> to <code>10</code>.\nSo before starting yo...
2014/12/27
[ "https://wordpress.stackexchange.com/questions/173324", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13058/" ]
We suppose that a category has 1000 posts, we can use the following code to show 10 posts per page and the wp pagenavi would present 100 pages with links of above 1000 posts. ``` <?php query_posts($query_string."&showposts=10&orderby=date&order=ASC") ?> ``` Is there any way that I show only 100 recent posts and hid...
AFAIK, there is no way limiting the amount of paged queries with what is given by default. You might be able to make use of the filters provided to alter the SQL query. You also do not want to use `query_posts` at all and most probably you don't even need a custom query. If this is the main query, you would want to ma...
173,328
<p>I just made a built-in translation function to help users to translate their theme from theme options.</p> <p>Usually my functions works great as follow:</p> <pre><code>&lt;?php _e( 'No Comments', 'mytextdomain' ); ?&gt; </code></pre> <p>becomes: </p> <pre><code>&lt;?php echo __myfunction( 'no_comments' ); ?&gt;...
[ { "answer_id": 173331, "author": "Mayeenul Islam", "author_id": 22728, "author_profile": "https://wordpress.stackexchange.com/users/22728", "pm_score": 0, "selected": false, "text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/esc_attr_e\" rel=\"nofollow\"><cod...
2014/12/27
[ "https://wordpress.stackexchange.com/questions/173328", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33903/" ]
I just made a built-in translation function to help users to translate their theme from theme options. Usually my functions works great as follow: ``` <?php _e( 'No Comments', 'mytextdomain' ); ?> ``` becomes: ``` <?php echo __myfunction( 'no_comments' ); ?> ``` My question is related to `esc_attr__` and I'm st...
As your function returns the translated string, you could pass the translation function as parameter for `esc_attr()` and `esc_attr_e()`: ``` esc_attr__( __myfunction( 'no_comments' ) ); esc_attr_e( __myfunction( 'no_comments' ) ); ``` But `esc_attr__()` and `esc_attr_e()` will perform translation tasks that you don...
173,360
<p>I have a client who is requesting that all posts of a certain custom post type (called 'custom-jobs') be set to automatically be included in the sitemap in the Yoast SEO plugin. </p> <p>I found that in order to do this, the post needs a meta key of '_yoast_wpseo_sitemap-include' with a value of 'always'. So I atte...
[ { "answer_id": 173361, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 2, "selected": true, "text": "<p>You are usgin an undefined <code>$post-&gt;ID</code> variable because there is no reference to any <code>$post...
2014/12/27
[ "https://wordpress.stackexchange.com/questions/173360", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65291/" ]
I have a client who is requesting that all posts of a certain custom post type (called 'custom-jobs') be set to automatically be included in the sitemap in the Yoast SEO plugin. I found that in order to do this, the post needs a meta key of '\_yoast\_wpseo\_sitemap-include' with a value of 'always'. So I attempted to...
You are usgin an undefined `$post->ID` variable because there is no reference to any `$post` object in your code; instead, use the `$post_ID` variable retrieved in the function: ``` function on_jobs_publish( $post_ID ) { global $wpdb; $wpdb->insert( 'iCrewzWp_postmeta', array( ...
173,378
<p>I have a strange problem I'm facing when using WP_Query with multisite in a plugin I'm writing which hooks into add_meta_boxes. I'm wanting to display all post titles in a dropdown in a meta box.</p> <p>While adding or editing a post in blog no. 2 (it could be any blog no.), I am looping through blog no. 1 and gett...
[ { "answer_id": 173361, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 2, "selected": true, "text": "<p>You are usgin an undefined <code>$post-&gt;ID</code> variable because there is no reference to any <code>$post...
2014/12/28
[ "https://wordpress.stackexchange.com/questions/173378", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65295/" ]
I have a strange problem I'm facing when using WP\_Query with multisite in a plugin I'm writing which hooks into add\_meta\_boxes. I'm wanting to display all post titles in a dropdown in a meta box. While adding or editing a post in blog no. 2 (it could be any blog no.), I am looping through blog no. 1 and getting pos...
You are usgin an undefined `$post->ID` variable because there is no reference to any `$post` object in your code; instead, use the `$post_ID` variable retrieved in the function: ``` function on_jobs_publish( $post_ID ) { global $wpdb; $wpdb->insert( 'iCrewzWp_postmeta', array( ...
173,380
<p>I asked <a href="https://wordpress.stackexchange.com/questions/173197/upload-multiple-files-with-media-handle-upload">this question</a> about few days ago and the answer solved my instantly problem but now when I tried to put many file fields in the form just the first field work because the solution of my previous ...
[ { "answer_id": 173361, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 2, "selected": true, "text": "<p>You are usgin an undefined <code>$post-&gt;ID</code> variable because there is no reference to any <code>$post...
2014/12/28
[ "https://wordpress.stackexchange.com/questions/173380", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64134/" ]
I asked [this question](https://wordpress.stackexchange.com/questions/173197/upload-multiple-files-with-media-handle-upload) about few days ago and the answer solved my instantly problem but now when I tried to put many file fields in the form just the first field work because the solution of my previous question overw...
You are usgin an undefined `$post->ID` variable because there is no reference to any `$post` object in your code; instead, use the `$post_ID` variable retrieved in the function: ``` function on_jobs_publish( $post_ID ) { global $wpdb; $wpdb->insert( 'iCrewzWp_postmeta', array( ...
173,382
<p>I have an <code>$array</code> that prints out to be as follows.</p> <p><code>Array ( [post-12] =&gt; 12 [post-160] =&gt; 160 )</code></p> <p>What WordPress function could I use to check how many of the post ID's in the array belong to a specific category, say category with ID 45.</p> <p>I tried doing the followin...
[ { "answer_id": 173383, "author": "Sam", "author_id": 4609, "author_profile": "https://wordpress.stackexchange.com/users/4609", "pm_score": 1, "selected": false, "text": "<p>I have successfully returned the counts using the following code. Just in case someone may later view this question...
2014/12/28
[ "https://wordpress.stackexchange.com/questions/173382", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4609/" ]
I have an `$array` that prints out to be as follows. `Array ( [post-12] => 12 [post-160] => 160 )` What WordPress function could I use to check how many of the post ID's in the array belong to a specific category, say category with ID 45. I tried doing the following. ``` $post_id_array = $array; $category = '45'; $...
A much faster solution would be to query the database once instead of over and over for each post ex: ``` function count_posts_in_term($posts = array(),$term_taxonomy_id = 0){ global $wpdb; $count = 0 ; $count = $wpdb->get_var( $wpdb->prepare("SELECT count(object_id) FROM $wpdb->term_r...
173,395
<p>I'm not sure if I phrased this question correctly... </p> <p>My wife and I have one blog, <em>family.com</em> in this example, that we both contribute to. </p> <p>I would like <em>family.com</em> to show all blog posts.</p> <p><em>me.family.com</em> would show only posts I author and <em>her.family.com</em> would...
[ { "answer_id": 173659, "author": "brianjohnhanna", "author_id": 65403, "author_profile": "https://wordpress.stackexchange.com/users/65403", "pm_score": 1, "selected": false, "text": "<p>Is there some reason you need subdomains over \"subdirectories\" (I put that in quotes because it won'...
2014/12/28
[ "https://wordpress.stackexchange.com/questions/173395", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48352/" ]
I'm not sure if I phrased this question correctly... My wife and I have one blog, *family.com* in this example, that we both contribute to. I would like *family.com* to show all blog posts. *me.family.com* would show only posts I author and *her.family.com* would show only posts she authors. later, we will add *ki...
wp-config.php ``` if ( is_alt_domain( $_SERVER['SERVER_NAME'] ) ) { $domain = str_replace( 'www.', '', $_SERVER['SERVER_NAME'] ); define( 'WP_SITEURL', 'http://www.' . $domain ); define( 'WP_HOME', 'http://www.' . $domain ); } else if (is_sub_domain( $_SERVER['HTTP_HOST'] ) ) { $domain = "{$_SERVER['HT...
173,406
<p>When I'm in "the loop" (archive pages etc.) how do I force teasers / excerpts for all articles, regardless of whether they contain the <code>&lt;!--more--&gt;</code> tag or not?</p> <p>Details:</p> <p>I'm starting off of the <code>_s</code> template which displays blog post content using <a href="https://github.co...
[ { "answer_id": 173407, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": true, "text": "<p><strong>EDIT</strong></p>\n\n<p>OK, there is a very hidden native function, <code>get_extended()</code> ...
2014/12/28
[ "https://wordpress.stackexchange.com/questions/173406", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12248/" ]
When I'm in "the loop" (archive pages etc.) how do I force teasers / excerpts for all articles, regardless of whether they contain the `<!--more-->` tag or not? Details: I'm starting off of the `_s` template which displays blog post content using [the `content.php` template](https://github.com/Automattic/_s/blob/mast...
**EDIT** OK, there is a very hidden native function, `get_extended()` that I never knew about and greatly explained by @kaiser in [his answer](https://wordpress.stackexchange.com/a/173410/31545). My answer should only be an extension to the answer by @kaiser **ORIGINAL ANSWER** There is no native function to do this...
173,414
<p>disclaimer: this is my first foray into wordpress </p> <p>I'm creating a custom theme and in the <code>single.php</code> file, i have the main loop, however if i navigate to different posts, all that shows up is the latest post. I could go to the different permalinks, but the only post that shows up is the latest ...
[ { "answer_id": 173416, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>When you call <code>setup_postdata($post);</code>, that populates the global <code>$post</code> with the current p...
2014/12/28
[ "https://wordpress.stackexchange.com/questions/173414", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65133/" ]
disclaimer: this is my first foray into wordpress I'm creating a custom theme and in the `single.php` file, i have the main loop, however if i navigate to different posts, all that shows up is the latest post. I could go to the different permalinks, but the only post that shows up is the latest one. How do I make it ...
I think that your structure here is wrong. I would completely remove your custom query from inside your loop and move it outside. Another option is to make use of other variable names in your custom query and making direct use of the [`WP_Post`](http://codex.wordpress.org/Class_Reference/WP_Post) objects As @Milo alre...
173,422
<p>How would you do a shortcode wrapper that can differentiate between different nested shortcodes.</p> <pre><code>[teaching_tool_wrapper param1="true" param2="false"] [chord param1="something"] [scale param1="something-else"] [/teaching_tool_wrapper] </code></pre> <p>I have it working fine with just the [cho...
[ { "answer_id": 173416, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>When you call <code>setup_postdata($post);</code>, that populates the global <code>$post</code> with the current p...
2014/12/28
[ "https://wordpress.stackexchange.com/questions/173422", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57391/" ]
How would you do a shortcode wrapper that can differentiate between different nested shortcodes. ``` [teaching_tool_wrapper param1="true" param2="false"] [chord param1="something"] [scale param1="something-else"] [/teaching_tool_wrapper] ``` I have it working fine with just the [chord] shortcode, however i'm...
I think that your structure here is wrong. I would completely remove your custom query from inside your loop and move it outside. Another option is to make use of other variable names in your custom query and making direct use of the [`WP_Post`](http://codex.wordpress.org/Class_Reference/WP_Post) objects As @Milo alre...
173,455
<p>I am migrating my WP website from staging to production and I have a problem with Dashboard access.</p> <p>When I try to access</p> <pre><code>http://&lt;domain&gt;/wp-admin.php </code></pre> <p>it redirects me to</p> <pre><code>http://./wp-login.php?redirect_to=http%3A%2F%2F&lt;domain&gt;%2Fwp-admin%2F&amp;reau...
[ { "answer_id": 173460, "author": "Dan", "author_id": 42582, "author_profile": "https://wordpress.stackexchange.com/users/42582", "pm_score": 0, "selected": false, "text": "<p>I advise you to:</p>\n\n<ol>\n<li>Go to <em>/wp-admin/options-general.php</em> and see if your site urls are\ncor...
2014/12/29
[ "https://wordpress.stackexchange.com/questions/173455", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32958/" ]
I am migrating my WP website from staging to production and I have a problem with Dashboard access. When I try to access ``` http://<domain>/wp-admin.php ``` it redirects me to ``` http://./wp-login.php?redirect_to=http%3A%2F%2F<domain>%2Fwp-admin%2F&reauth=1 ``` I can login with going directly to `http://<domai...
Possible solution: \* go to permalinks under settings and check URL structure with your desired domain name. Even if the URL seems to be right, click the desired structure and save. This was handy while i migrated 2 websites. or \* look for "wp\_options" table in your database. You will find "*siteurl*" & "*baseurl*" r...
173,469
<p>I would like to know how I can loop through pages with a specific template name. I have several pages where the admin can select a template name of <code>SALE</code>. I want to display all content with this template name via the loop. </p> <p>Any ideas are much appreciated!</p>
[ { "answer_id": 173494, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>Use <code>get_template_part</code>, for example if your template is named <em>sale.php</em> you can use:</p>\n\n<p...
2014/12/29
[ "https://wordpress.stackexchange.com/questions/173469", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49869/" ]
I would like to know how I can loop through pages with a specific template name. I have several pages where the admin can select a template name of `SALE`. I want to display all content with this template name via the loop. Any ideas are much appreciated!
Wordpress saves page templates that is assigned to a specific page in the db in the `wp_postmeta` table. These are saved as follows: ``` 'meta_key' => '_wp_page_template', 'meta_value' => 'NAME_ OF_TEMPLATE' ``` With this in mind, you can loop through pages which shares a specific page template, using `get_pages` (...
173,478
<p>I have my posts page set as <code>index.php</code>, and on there I have my main heading (as I do on all pages).</p> <p>I'm having trouble displaying the page's heading however. The page is called 'Blog' in WordPress, and has been specified as the posts page.</p> <p>If I output the page heading with <code>wp_title(...
[ { "answer_id": 178218, "author": "user781470", "author_id": 67531, "author_profile": "https://wordpress.stackexchange.com/users/67531", "pm_score": 4, "selected": true, "text": "<p>Strange. Outside the loop, the_title() <em>should</em> give you the current page name, <em>if</em> you real...
2014/12/29
[ "https://wordpress.stackexchange.com/questions/173478", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I have my posts page set as `index.php`, and on there I have my main heading (as I do on all pages). I'm having trouble displaying the page's heading however. The page is called 'Blog' in WordPress, and has been specified as the posts page. If I output the page heading with `wp_title('');`, I get the title of the pag...
Strange. Outside the loop, the\_title() *should* give you the current page name, *if* you really are on a page, and not viewing a specific post. If it gives post title instead, it may mean that you are somehow inside a loop. But if that were true, wp\_title shouldn't show "Blog". See if other options give the same res...
173,511
<p>I made a custom post type and on saving its additional data I want to check if I a published post exists by its name. It works alright if there is, but I would like to throw some notice if article is not found.</p> <pre><code> $post_exists = $wpdb-&gt;get_row("SELECT post_name FROM wp_posts WHERE post_name = '" ...
[ { "answer_id": 173512, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>The notice is easy to set via the hook <code>admin_notices</code>. You can set on each page a message via this ho...
2014/12/29
[ "https://wordpress.stackexchange.com/questions/173511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47357/" ]
I made a custom post type and on saving its additional data I want to check if I a published post exists by its name. It works alright if there is, but I would like to throw some notice if article is not found. ``` $post_exists = $wpdb->get_row("SELECT post_name FROM wp_posts WHERE post_name = '" . $_POST['article...
You can use `admin_notices` hook <http://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices> For example: ``` function ravs_admin_notice() { ?> <div class="error"> <p><?php _e( 'Article with this title is not found!', 'my-text-domain' ); ?></p> </div> <?php } ``` on `publish_{your...
173,517
<p>I am trying to create new WordPress theme from scratch. I have working html, css and js files. To add JS into wordpress theme I used:</p> <pre><code>function my_scripts_styles() { wp_enqueue_script( 'easing', get_template_directory_uri() . '/js/easing.js', '2014-12-030', true ); } add_action( 'wp_enqueue_scri...
[ { "answer_id": 173521, "author": "Amit Mishra", "author_id": 47962, "author_profile": "https://wordpress.stackexchange.com/users/47962", "pm_score": 0, "selected": false, "text": "<p>Add this function in your functions.php file to enqueue your script like this and put the <code>wp_header...
2014/12/29
[ "https://wordpress.stackexchange.com/questions/173517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65348/" ]
I am trying to create new WordPress theme from scratch. I have working html, css and js files. To add JS into wordpress theme I used: ``` function my_scripts_styles() { wp_enqueue_script( 'easing', get_template_directory_uri() . '/js/easing.js', '2014-12-030', true ); } add_action( 'wp_enqueue_scripts', 'my_scri...
Your code should look like this ``` function my_scripts_styles() { wp_register_script('easing', get_template_directory_uri() . '/js/easing.js', '2014-12-030', true ); wp_enqueue_script('easing'); } add_action( 'wp_enqueue_scripts', 'my_scripts_styles' ); ``` The above code should work fine. Also don't for...
173,522
<p>I'd like to fully customize the CSS and HTML of the main blog page (index.php) and the individual post page (single.php). However, looking in index.php and single.php, I don't see how to get at the HTML/CSS I'm looking for, as it appears to be doing this with external PHP functions.</p> <p>As an example, I'd like t...
[ { "answer_id": 173523, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>What you are seeing in template files <strong>is</strong> “actual” code. WordPress is PHP application and its templ...
2014/12/29
[ "https://wordpress.stackexchange.com/questions/173522", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64956/" ]
I'd like to fully customize the CSS and HTML of the main blog page (index.php) and the individual post page (single.php). However, looking in index.php and single.php, I don't see how to get at the HTML/CSS I'm looking for, as it appears to be doing this with external PHP functions. As an example, I'd like to have my ...
hey add the following code in your index.php file to show the three recent blog post like this ``` <?php query_posts(array( 'post_type' => 'post', 'posts_per_page' => 3, 'order' => 'ASC', )); ?> ...
173,583
<p>I am building a Bootstrap / WordPress <a href="http://turtles.opteradev.com" rel="nofollow">site</a> and I am having an issue with bootstrap.min.js loading before jquery, which results in issues like the navigation not working correctly.</p> <p>Here is how I have the scripts enqueued. </p> <pre><code>function turt...
[ { "answer_id": 173584, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 3, "selected": true, "text": "<p>In place of your emnpty <code>array()</code> you are able to declare dependencies. For Script A to load befor...
2014/12/30
[ "https://wordpress.stackexchange.com/questions/173583", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48611/" ]
I am building a Bootstrap / WordPress [site](http://turtles.opteradev.com) and I am having an issue with bootstrap.min.js loading before jquery, which results in issues like the navigation not working correctly. Here is how I have the scripts enqueued. ``` function turtles_scripts() { wp_enqueue_style( 'turtles-...
In place of your emnpty `array()` you are able to declare dependencies. For Script A to load before Script B, declare that A is dependent on B. Codex reference: <http://codex.wordpress.org/Function_Reference/wp_enqueue_script> It's possible you have declared these dependencies within your register statements but thes...
173,601
<p>I have this in my <code>functions.php</code> file and I can't get jQuery to load in the footer. The <code>includes</code> file loads in the footer fine, though. What else do I need to do?</p> <pre><code>function starter_scripts() { wp_enqueue_style( 'starter-style', get_stylesheet_uri() ); wp_enqueue_scrip...
[ { "answer_id": 173603, "author": "Amit Mishra", "author_id": 47962, "author_profile": "https://wordpress.stackexchange.com/users/47962", "pm_score": -1, "selected": false, "text": "<p>Hey only change your code to like this </p>\n\n<pre><code>function starter_scripts() {\n wp_enque...
2014/12/30
[ "https://wordpress.stackexchange.com/questions/173601", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18320/" ]
I have this in my `functions.php` file and I can't get jQuery to load in the footer. The `includes` file loads in the footer fine, though. What else do I need to do? ``` function starter_scripts() { wp_enqueue_style( 'starter-style', get_stylesheet_uri() ); wp_enqueue_script( 'jquery', '', '', '', true ); ...
To do that you will first have to deregister your jQuery script and then register again. If you use jQuery comes with WordPress then following is the function your are looking for. ``` function starter_scripts() { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', includes_url( '/js/jquery/jquery....
173,607
<p>I am currently trying to do a directory style site, and I currently have parent categories and child categories.</p> <p>Right now, I have the parent categories showing and when a parent category link is clicked I'm using <code>category.php</code> to show the list of child categories.</p> <p>Now I want to that when...
[ { "answer_id": 173603, "author": "Amit Mishra", "author_id": 47962, "author_profile": "https://wordpress.stackexchange.com/users/47962", "pm_score": -1, "selected": false, "text": "<p>Hey only change your code to like this </p>\n\n<pre><code>function starter_scripts() {\n wp_enque...
2014/12/30
[ "https://wordpress.stackexchange.com/questions/173607", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65377/" ]
I am currently trying to do a directory style site, and I currently have parent categories and child categories. Right now, I have the parent categories showing and when a parent category link is clicked I'm using `category.php` to show the list of child categories. Now I want to that when a child category link is cl...
To do that you will first have to deregister your jQuery script and then register again. If you use jQuery comes with WordPress then following is the function your are looking for. ``` function starter_scripts() { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', includes_url( '/js/jquery/jquery....
173,626
<p>I am trying to display user's avatar/profile image when logged in, but when I use this:</p> <pre><code> &lt;?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user-&gt;ID, 64 ); </code></pre> <p>?></p> <p>it displays the default_avatar_male.jpg, but I don't want anything ...
[ { "answer_id": 173627, "author": "Rohil_PHPBeginner", "author_id": 59321, "author_profile": "https://wordpress.stackexchange.com/users/59321", "pm_score": 0, "selected": false, "text": "<p>You can wrap this code in to a condition that <strong>if</strong> user is <code>logged in</code> th...
2014/12/31
[ "https://wordpress.stackexchange.com/questions/173626", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58774/" ]
I am trying to display user's avatar/profile image when logged in, but when I use this: ``` <?php global $current_user; get_currentuserinfo(); echo get_avatar( $current_user->ID, 64 ); ``` ?> it displays the default\_avatar\_male.jpg, but I don't want anything to be displayed unless logged in. Tha...
Hey pass the current user email id in get\_avatar() function if user is logged in like this ``` <?php if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); if ( ($current_user instanceof WP_User) ) { echo 'Welcome : ' . esc_html( $current_user->display_name ); echo get_avatar( $c...
173,637
<p>I have this script (found online) to import the values of an input form field as a taxonomy term. I got it working, but now I'd like to import/save the values of multiple form fields. Now all it does is import the value of the field 'input_name' as a taxonomy term. But, lets say, I'd like to import the values of 'in...
[ { "answer_id": 173627, "author": "Rohil_PHPBeginner", "author_id": 59321, "author_profile": "https://wordpress.stackexchange.com/users/59321", "pm_score": 0, "selected": false, "text": "<p>You can wrap this code in to a condition that <strong>if</strong> user is <code>logged in</code> th...
2014/12/31
[ "https://wordpress.stackexchange.com/questions/173637", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32810/" ]
I have this script (found online) to import the values of an input form field as a taxonomy term. I got it working, but now I'd like to import/save the values of multiple form fields. Now all it does is import the value of the field 'input\_name' as a taxonomy term. But, lets say, I'd like to import the values of 'inpu...
Hey pass the current user email id in get\_avatar() function if user is logged in like this ``` <?php if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); if ( ($current_user instanceof WP_User) ) { echo 'Welcome : ' . esc_html( $current_user->display_name ); echo get_avatar( $c...
173,702
<p>I have almost no experience in creating widget area's and I am stuck at saving the widgets in the widget area 'red menu'. I have searched a dozen posts but I can't seem to get it working.</p> <p>I am currently working in Wordpress 4.0.1 and this is the code I have:</p> <p><em>Widgets.php:</em> <pre><code>cla...
[ { "answer_id": 173710, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": true, "text": "<p>This line of code is incorrect</p>\n\n<pre><code>&lt;?php if ( !function_exists('redmenu_widget') || !dy...
2015/01/01
[ "https://wordpress.stackexchange.com/questions/173702", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65425/" ]
I have almost no experience in creating widget area's and I am stuck at saving the widgets in the widget area 'red menu'. I have searched a dozen posts but I can't seem to get it working. I am currently working in Wordpress 4.0.1 and this is the code I have: *Widgets.php:* ``` class Red_Menu_Widget extends WP_Widget...
This line of code is incorrect ``` <?php if ( !function_exists('redmenu_widget') || !dynamic_sidebar('redmenu_widget') ) : ?> ``` More to the point, your negative operator (`!`) is wrong here That line of code simply translates to > > If the function `redmenu_widget` does not exist OR if the sidebar `redmenu_wid...
173,705
<p>It should be simple, but I tried some codes, none does the trick. Searched on Google, nothing there either. Simply check if the comment author is a registered user (so I can add some code for it), if it's not registered show nothing.</p> <p>This should do the trick <code>if( empty($comment_author_nickname) &amp;&...
[ { "answer_id": 173706, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 1, "selected": false, "text": "<p>I don't think there is any safe and reliable method to do this. In my honest opinion, this is also some...
2015/01/01
[ "https://wordpress.stackexchange.com/questions/173705", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6927/" ]
It should be simple, but I tried some codes, none does the trick. Searched on Google, nothing there either. Simply check if the comment author is a registered user (so I can add some code for it), if it's not registered show nothing. This should do the trick `if( empty($comment_author_nickname) && empty($comment_aut...
I wonder if you mean this kind of check: ``` if( $comment->user_id > 0 ) { // Registered comment author } ``` in your comment's template callback. This is determined in the the `wp-comments-post.php` file: ``` $commentdata = compact('comment_post_ID', ..., 'user_ID' ); $comment_id = wp_new_comment( $commentd...
173,717
<p>I have a custom query to display content of a certain template:</p> <pre><code>&lt;?php $i = 0; $pages = get_pages(array( 'meta_key' =&gt; '_wp_page_template', 'meta_value' =&gt; 'sale.php' )); foreach($pages as $page){ echo '&lt;div class="content_'. $i .'"&gt;' . apply_filt...
[ { "answer_id": 173718, "author": "Robert hue", "author_id": 22461, "author_profile": "https://wordpress.stackexchange.com/users/22461", "pm_score": 0, "selected": false, "text": "<p>You can print custom filed value with <code>get_field</code> function in ACF you can do this.</p>\n\n<p>In...
2015/01/01
[ "https://wordpress.stackexchange.com/questions/173717", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49869/" ]
I have a custom query to display content of a certain template: ``` <?php $i = 0; $pages = get_pages(array( 'meta_key' => '_wp_page_template', 'meta_value' => 'sale.php' )); foreach($pages as $page){ echo '<div class="content_'. $i .'">' . apply_filters( 'the_content', $page->po...
In general, you need to pass the page ID to `the_field` and for that matter `get_post_meta` as well You can try the following ``` the_field( 'sale_images_url', $page->ID ); ```
173,719
<p>Wordpress let you choose between <code>thumb</code> <code>medium</code> <code>large</code> and <code>full</code> size when uploading and inserting an image into a post or a page.</p> <p>The meaning of <code>full</code> is obvious. But how WordPress set size for <code>thumb</code> (I seem to remember 150x150 and in ...
[ { "answer_id": 173725, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>The default post thumbnail/image sizes are set as follows</p>\n\n<ul>\n<li>thumb 150x150</li>\n<li>medi...
2015/01/01
[ "https://wordpress.stackexchange.com/questions/173719", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20109/" ]
Wordpress let you choose between `thumb` `medium` `large` and `full` size when uploading and inserting an image into a post or a page. The meaning of `full` is obvious. But how WordPress set size for `thumb` (I seem to remember 150x150 and in some cases 200x200), `medium` and `large`? Are there fixed sizes or can th...
The defaults are `Thumbnail 150x150`, `Medium 300x300`, and `Large 1024x1024`. The fixed values can be changed in the admin dashboard under [Settings > Media](http://codex.wordpress.org/Settings_Media_Screen). You can also change them in your theme's functions.php: ``` update_option( 'thumbnail_size_w', 160 ); // Set ...
173,733
<p>I am going to implement a favorite post system so users can save their favorite posts for later reading.</p> <p>I want to know what is the best approach for doing it taking into considaration the possibility that hundreds of thousands of users will use this function. Users will be able to see their favorite posts i...
[ { "answer_id": 173734, "author": "Andy", "author_id": 43719, "author_profile": "https://wordpress.stackexchange.com/users/43719", "pm_score": 0, "selected": false, "text": "<p><strong>UPDATE:</strong> I didn't see the part in your question about users being able to see a page of the favo...
2015/01/01
[ "https://wordpress.stackexchange.com/questions/173733", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14128/" ]
I am going to implement a favorite post system so users can save their favorite posts for later reading. I want to know what is the best approach for doing it taking into considaration the possibility that hundreds of thousands of users will use this function. Users will be able to see their favorite posts in a custom...
Use a custom table. Create it as a network table, and store the site ID, so you can use just *one table* for the whole network. ``` row_id | site_id | post_id | user_id ``` There is no equivalent for such a table in the current core tables. Avoid serialized data, because that format is PHP specific, so you cannot r...
173,736
<p>I have a blog for my official website. I allow people for commenting on my blog but i don't want to get comment from auto-bot. Therefore, i am thinking of to add an extra field which is called "security question" to the comment form. But i don't know how to make it work.</p> <p>This is the code i have for processin...
[ { "answer_id": 173734, "author": "Andy", "author_id": 43719, "author_profile": "https://wordpress.stackexchange.com/users/43719", "pm_score": 0, "selected": false, "text": "<p><strong>UPDATE:</strong> I didn't see the part in your question about users being able to see a page of the favo...
2015/01/02
[ "https://wordpress.stackexchange.com/questions/173736", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23036/" ]
I have a blog for my official website. I allow people for commenting on my blog but i don't want to get comment from auto-bot. Therefore, i am thinking of to add an extra field which is called "security question" to the comment form. But i don't know how to make it work. This is the code i have for processing my exist...
Use a custom table. Create it as a network table, and store the site ID, so you can use just *one table* for the whole network. ``` row_id | site_id | post_id | user_id ``` There is no equivalent for such a table in the current core tables. Avoid serialized data, because that format is PHP specific, so you cannot r...
173,739
<p>I'd like to know how to order by "random" instead of by "date". </p> <p>Can someone help me modify this so it gets posts randomly instead of by date?</p> <pre><code>$posts = get_posts('numberposts=5&amp;orderby=date&amp;fields=all&amp;tag='.$tag); </code></pre> <p>Thank you!</p>
[ { "answer_id": 173740, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 3, "selected": true, "text": "<pre><code>$randomPosts = get_posts(array(\n 'orderby' =&gt; 'rand',\n 'posts_per_page' =&gt; 5,\n 'ta...
2015/01/02
[ "https://wordpress.stackexchange.com/questions/173739", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64181/" ]
I'd like to know how to order by "random" instead of by "date". Can someone help me modify this so it gets posts randomly instead of by date? ``` $posts = get_posts('numberposts=5&orderby=date&fields=all&tag='.$tag); ``` Thank you!
``` $randomPosts = get_posts(array( 'orderby' => 'rand', 'posts_per_page' => 5, 'tag' => $tag, )); ``` Take a gander at the [`WP_Query` documentation](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters). [`get_posts`](http://codex.wordpress.org/Template_Tags/get_posts) uses `WP_...
173,751
<p>I am going to implement a Hot and Trending section on a website. I have seen such sections on many popular websites but can't really figure out how exactly this works.</p> <p>Although I assumed <code>Hot section</code> is most popular posts (based on post views) which I developed by a custom <code>WP_Query</code>. ...
[ { "answer_id": 173754, "author": "Shady M Rasmy", "author_id": 17025, "author_profile": "https://wordpress.stackexchange.com/users/17025", "pm_score": 0, "selected": false, "text": "<p>Trending is done by using between two values ,</p>\n\n<p><strong>Example</strong> </p>\n\n<ul>\n<li>pos...
2015/01/02
[ "https://wordpress.stackexchange.com/questions/173751", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22461/" ]
I am going to implement a Hot and Trending section on a website. I have seen such sections on many popular websites but can't really figure out how exactly this works. Although I assumed `Hot section` is most popular posts (based on post views) which I developed by a custom `WP_Query`. And it works. ``` $args = array...
In my personal opinion, this can get a bit resource intensive, so you will need to implement some type of cache system, or even look at transient What you want to do is to extent your current post view function or even create one on the side for this. You would want to capture each view twice, once for normal page vie...
173,783
<p>Is it possible to move the sidebar in the TwentyFifteen theme to the right using a child theme and CSS only, or does it require changes to the theme itself? The main issue I'm running into is that I can get the sidebar on the right side in either the "default" or the "scrolled" scenario, but not in both (default use...
[ { "answer_id": 173798, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>I took the following from the <code>rtl.css</code> and applied them via <a href=\"https://wordpress.org/plugins/magic-...
2015/01/02
[ "https://wordpress.stackexchange.com/questions/173783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65454/" ]
Is it possible to move the sidebar in the TwentyFifteen theme to the right using a child theme and CSS only, or does it require changes to the theme itself? The main issue I'm running into is that I can get the sidebar on the right side in either the "default" or the "scrolled" scenario, but not in both (default uses p...
I took the following from the `rtl.css` and applied them via [Magic Widget](https://wordpress.org/plugins/magic-widgets/) with additional `!important` keywords to an English site: ``` body:before { right: 0 !important; left: auto !important; } .sidebar { float: right !important; margin-right: auto !imp...
173,797
<p>Somewhere off of the homepage we need to show a container page which does some stuff with custom post types. Actually it doesn't matter what it does, my point is it needs to exist and be reachable from the homepage menu.</p> <p>We have done this before and created a WordPress "page" to operate as a container page a...
[ { "answer_id": 173799, "author": "Hasin Hayder", "author_id": 12927, "author_profile": "https://wordpress.stackexchange.com/users/12927", "pm_score": 0, "selected": false, "text": "<p>Well, inside your directory just keep a normal php file like my-page.php, and then create a vanity URL f...
2015/01/02
[ "https://wordpress.stackexchange.com/questions/173797", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/875/" ]
Somewhere off of the homepage we need to show a container page which does some stuff with custom post types. Actually it doesn't matter what it does, my point is it needs to exist and be reachable from the homepage menu. We have done this before and created a WordPress "page" to operate as a container page and then in...
Well, inside your directory just keep a normal php file like my-page.php, and then create a vanity URL for it using .htaccess. Open your .htaccess file (if present in the nstallation directory) or create one ``` RewriteEngine On RewriteRule ^my-page-slug my-page.php ``` Should be good update ------ if you want to ...
173,802
<p>im trying to display my WP loop with this layout:</p> <pre><code>(POST 1) (POST 2)/ (POST 3) (POST 4) (POST 5)/ (POST 6) (POST 7)/ (POST 8) (POST 9) (POST 10) </code></pre> <p>and so goes on. Any ideas? Thank you very much.</p>
[ { "answer_id": 173803, "author": "Hasin Hayder", "author_id": 12927, "author_profile": "https://wordpress.stackexchange.com/users/12927", "pm_score": 1, "selected": false, "text": "<p>Yes you can do that using $wp_query->current_post inside the loop. It returns the current posts index nu...
2015/01/02
[ "https://wordpress.stackexchange.com/questions/173802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65460/" ]
im trying to display my WP loop with this layout: ``` (POST 1) (POST 2)/ (POST 3) (POST 4) (POST 5)/ (POST 6) (POST 7)/ (POST 8) (POST 9) (POST 10) ``` and so goes on. Any ideas? Thank you very much.
Yes you can do that using $wp\_query->current\_post inside the loop. It returns the current posts index number inside the loop (starting form 0). Have a look at the following code block ``` <?php global $wp_query; while(have_posts()){ the_post(); the_title(); //do your other stuff if($wp_query->curren...
173,811
<p>Im using geoplugin.com to display content based on users location the codex is set up like this:</p> <pre><code>$geoplugin = unserialize( file_get_contents('http://www.geoplugin.net/php.gp? ip=' . $_SERVER['REMOTE_ADDR']) ); </code></pre> <p>This works on my dev site but not on my live site. I tried to use w...
[ { "answer_id": 173803, "author": "Hasin Hayder", "author_id": 12927, "author_profile": "https://wordpress.stackexchange.com/users/12927", "pm_score": 1, "selected": false, "text": "<p>Yes you can do that using $wp_query->current_post inside the loop. It returns the current posts index nu...
2015/01/02
[ "https://wordpress.stackexchange.com/questions/173811", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63922/" ]
Im using geoplugin.com to display content based on users location the codex is set up like this: ``` $geoplugin = unserialize( file_get_contents('http://www.geoplugin.net/php.gp? ip=' . $_SERVER['REMOTE_ADDR']) ); ``` This works on my dev site but not on my live site. I tried to use wp\_remote\_get but couldnt...
Yes you can do that using $wp\_query->current\_post inside the loop. It returns the current posts index number inside the loop (starting form 0). Have a look at the following code block ``` <?php global $wp_query; while(have_posts()){ the_post(); the_title(); //do your other stuff if($wp_query->curren...
173,818
<p>When a user loses their password in WordPress, you are prompted to enter your <strong>email</strong> or <strong>username</strong>.</p> <p>When the password reset email has been sent, it displays "wordpress" as a sender name. I want my website or blogname to replace that instead. </p> <p>I would rather send my own ...
[ { "answer_id": 239884, "author": "Jeremy Ross", "author_id": 102007, "author_profile": "https://wordpress.stackexchange.com/users/102007", "pm_score": 3, "selected": false, "text": "<p>If you have a custom login page already, you may not want to introduce a whole new plugin. You can chan...
2015/01/03
[ "https://wordpress.stackexchange.com/questions/173818", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65467/" ]
When a user loses their password in WordPress, you are prompted to enter your **email** or **username**. When the password reset email has been sent, it displays "wordpress" as a sender name. I want my website or blogname to replace that instead. I would rather send my own personal email and link to the users my sel...
If you have a custom login page already, you may not want to introduce a whole new plugin. You can change 'from' name and email with these simple functions in your theme or plugin. **To change the name** ``` add_filter( 'wp_mail_from_name', 'custom_wpse_mail_from_name' ); function custom_wpse_mail_from_name( $origina...
173,844
<p>Lets say I have a theme option or custom postmeta text area. Now I want to execute multiple shortcodes, general texts, images etc.</p> <p>What will be best practice and why?</p> <p>Option 1:</p> <pre><code>$content = //my text area data; echo apply_filters('the_content', $content); </code></pre> <p>Option 2:</p>...
[ { "answer_id": 173847, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 4, "selected": false, "text": "<h1>QUESTION AND ANSWER REVISITED</h1>\n<p>There are sometimes these questions that nags you and hunts you...
2015/01/03
[ "https://wordpress.stackexchange.com/questions/173844", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28744/" ]
Lets say I have a theme option or custom postmeta text area. Now I want to execute multiple shortcodes, general texts, images etc. What will be best practice and why? Option 1: ``` $content = //my text area data; echo apply_filters('the_content', $content); ``` Option 2: ``` $content = //my text area data; echo d...
QUESTION AND ANSWER REVISITED ============================= There are sometimes these questions that nags you and hunts you down later in life again, and this is one such question. This question had me thinking about an alternative solution to the problem. As I already stated, custom fields and meta boxes are there t...
173,855
<p>I am looking for a way to reproduce what is described in the documentation: <a href="http://codex.wordpress.org/Shortcode_API#Handling_Attributes" rel="nofollow">An overloaded shortcode callback.</a></p> <p>According to the docs, the <code>$atts</code> array will contain the string that matched the shortcode RegEx....
[ { "answer_id": 173847, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 4, "selected": false, "text": "<h1>QUESTION AND ANSWER REVISITED</h1>\n<p>There are sometimes these questions that nags you and hunts you...
2015/01/03
[ "https://wordpress.stackexchange.com/questions/173855", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12580/" ]
I am looking for a way to reproduce what is described in the documentation: [An overloaded shortcode callback.](http://codex.wordpress.org/Shortcode_API#Handling_Attributes) According to the docs, the `$atts` array will contain the string that matched the shortcode RegEx. The position inside `$atts` depends on if the ...
QUESTION AND ANSWER REVISITED ============================= There are sometimes these questions that nags you and hunts you down later in life again, and this is one such question. This question had me thinking about an alternative solution to the problem. As I already stated, custom fields and meta boxes are there t...
173,871
<p>I'm trying to create a set of legal pages, that I can add to any WordPress site.</p> <p>Within these pages, I want to mention the site name. Is there a built in shortcode or something, that I can include in the pages to allow for this?</p> <p>For example, I would create a Privacy Page with a variable/shortcode tha...
[ { "answer_id": 173876, "author": "flomei", "author_id": 65455, "author_profile": "https://wordpress.stackexchange.com/users/65455", "pm_score": 0, "selected": false, "text": "<p>I don´t think that is possible without altering the functions.php or some kind of plugin. </p>\n\n<p>You have ...
2015/01/03
[ "https://wordpress.stackexchange.com/questions/173871", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65484/" ]
I'm trying to create a set of legal pages, that I can add to any WordPress site. Within these pages, I want to mention the site name. Is there a built in shortcode or something, that I can include in the pages to allow for this? For example, I would create a Privacy Page with a variable/shortcode that will display th...
No, there is no core shortcode for this. The site name is available as an option, in facts [`get_option('blogname')`](http://codex.wordpress.org/Function_Reference/get_option) returns the blog name. Moreover, [`get_bloginfo('name')`](http://codex.wordpress.org/Function_Reference/get_bloginfo) / [`bloginfo('name')`](h...
173,892
<p>I want to show the custom taxonomy name on the listing of custom post type on my front end</p>
[ { "answer_id": 173893, "author": "Pratik bhatt", "author_id": 60922, "author_profile": "https://wordpress.stackexchange.com/users/60922", "pm_score": 1, "selected": true, "text": "<p>You can use following code in the custom post type listing template</p>\n\n<pre><code>&lt;?php the_terms(...
2015/01/04
[ "https://wordpress.stackexchange.com/questions/173892", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60922/" ]
I want to show the custom taxonomy name on the listing of custom post type on my front end
You can use following code in the custom post type listing template ``` <?php the_terms( $post->ID, 'custom_taxonomy_name' , ' ' ); ?> ```
173,922
<p>I am trying to retrieve the previous and the 2nd previous posts' featured image as well as the two next posts' featured image. </p> <pre><code>&lt;div id="cooler-nav" class="navigation row"&gt; &lt;?php $prevPost = get_previous_post(true); if($prevPost) {?&gt; &lt;div class="nav-box previous col-md-3"&gt; ...
[ { "answer_id": 174003, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>The trick is that this function only works on <em>current</em> post. But that is something that you can adjust.</p>...
2015/01/04
[ "https://wordpress.stackexchange.com/questions/173922", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45007/" ]
I am trying to retrieve the previous and the 2nd previous posts' featured image as well as the two next posts' featured image. ``` <div id="cooler-nav" class="navigation row"> <?php $prevPost = get_previous_post(true); if($prevPost) {?> <div class="nav-box previous col-md-3"> <?php $prevthumbnail = get_th...
As I previously said in a comment > > You are using invalid values in `get_previous_post()` and `get_next_post()`. You are better of here writing your own function > > > I came up with the following. : * Get an array of all the posts and determine the current post's position. * Get the post ID's of the posts on ...
173,923
<p>I have created Custom Post type called "Natural Food" and displays the Post of this CPT Under </p> <blockquote> <p>Natural Food</p> </blockquote> <p>Menu, my index page also contains some post, as well as i want to display "Natural Food" post in index page how to do this. </p>
[ { "answer_id": 173935, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Add a function hooked to <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=\"nof...
2015/01/04
[ "https://wordpress.stackexchange.com/questions/173923", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64198/" ]
I have created Custom Post type called "Natural Food" and displays the Post of this CPT Under > > Natural Food > > > Menu, my index page also contains some post, as well as i want to display "Natural Food" post in index page how to do this.
Add a function hooked to [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) which modifies `post_type` argument of the main query to add your custom post type. ``` function wpd_home_post_types( $query ){ if( $query->is_home() && $query->is_main_query() ){ $query->set( '...
173,956
<p>I can't solve this problem. This started after I created a new sub domain. I can't update my plugins, install, delete.</p> <p>During an update it says "successfully update". After I goes back to my <code>plugin.php</code> it needs to be update again. I can't delete the plugin even it says "successfully deleted". An...
[ { "answer_id": 174363, "author": "Asha Krishna", "author_id": 65690, "author_profile": "https://wordpress.stackexchange.com/users/65690", "pm_score": -1, "selected": false, "text": "<p>try the following code in your wp-config file before doing anything in plugin</p>\n\n<pre><code> define...
2015/01/05
[ "https://wordpress.stackexchange.com/questions/173956", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65538/" ]
I can't solve this problem. This started after I created a new sub domain. I can't update my plugins, install, delete. During an update it says "successfully update". After I goes back to my `plugin.php` it needs to be update again. I can't delete the plugin even it says "successfully deleted". And also installing a n...
It is either an issue with your file system or with your mysql database. On some webhosting configurations, Wordpress automatic updates fail. In my experience, if it is not file permission, then it is an issue related to file ownership. Try the FTP method. Add the following lines in your wp-config.php ``` define('FS_...
174,019
<h2>Problem</h2> <p>I want the <code>height</code> and <code>width</code> properties in the <code>img</code> element of the Featured Image for a post, page, or custom post type.</p> <h2>Environment</h2> <ol> <li>I have a custom theme based on the <a href="https://wordpress.org/themes/blankslate" rel="nofollow">Blank...
[ { "answer_id": 174024, "author": "MMK", "author_id": 65350, "author_profile": "https://wordpress.stackexchange.com/users/65350", "pm_score": 2, "selected": false, "text": "<p>If you only want the size ( the width and the height ) of the image in the img tag like so</p>\n\n<pre><code>&lt;...
2015/01/05
[ "https://wordpress.stackexchange.com/questions/174019", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65279/" ]
Problem ------- I want the `height` and `width` properties in the `img` element of the Featured Image for a post, page, or custom post type. Environment ----------- 1. I have a custom theme based on the [BlankSlate theme](https://wordpress.org/themes/blankslate). 2. The new twentyfifteen theme also does not display ...
You can collect image attributes using "[wp\_get\_attachment\_metadata](http://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata)", see below example as starting point ``` function mytheme_post_thumbnail( $size = 'post-thumbnail', $attr = '', $post_id = null ) { if ( has_post_thumbnail( $post_id ) ...
174,067
<p>We are running WordPress and CodeIgniter in the same domain, separated by subfolders. We know it's not the best practice, but CodeIgniter will be a temporary thing until we fully move to WordPress.</p> <p>I was wondering if anybody could help me with an <code>.htaccess</code> file to allow WordPress and CodeIgniter...
[ { "answer_id": 174092, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>Your <code>.htaccess</code> rules are cascading from the level they are defined on downwards. So in this case whate...
2015/01/06
[ "https://wordpress.stackexchange.com/questions/174067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57380/" ]
We are running WordPress and CodeIgniter in the same domain, separated by subfolders. We know it's not the best practice, but CodeIgniter will be a temporary thing until we fully move to WordPress. I was wondering if anybody could help me with an `.htaccess` file to allow WordPress and CodeIgniter to run without clash...
Maybe try something like this.. `.htaccess` on your root: ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress ``` `.htaccess` ins...
174,117
<p>Can we have a sub-domain m.website.com for mobile users, those are automatically redirected to it?</p> <p>And what's the purpose anyway?</p>
[ { "answer_id": 174123, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>You can have a subdomain, but you cannot detect mobile users reliably. And you shouldn’t. </p>\n\n<h3>How to use a su...
2015/01/07
[ "https://wordpress.stackexchange.com/questions/174117", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37529/" ]
Can we have a sub-domain m.website.com for mobile users, those are automatically redirected to it? And what's the purpose anyway?
You can have a subdomain, but you cannot detect mobile users reliably. And you shouldn’t. ### How to use a subdomain with the same content In your `wp-config.php`, look at `$_SERVER['HTTP_HOST']`. If it matches `m.example.com`, enforce the current domain as main domain with … ``` const DOMAIN_CURRENT_SITE = 'm.exam...
174,124
<p>I'm working on a pro bono project to try to learn WordPress. I've been provided with a rough design (see screenshot below) and I'm struggling trying to think of how to approach the issue. </p> <p>My main issue is the whole image gallery side of it. In order to make it so that my client can take the site and not hav...
[ { "answer_id": 174127, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>Try to keep the business logic out of the theme. Dealing with images is always an edge case, because they <em>do</em> ...
2015/01/07
[ "https://wordpress.stackexchange.com/questions/174124", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65623/" ]
I'm working on a pro bono project to try to learn WordPress. I've been provided with a rough design (see screenshot below) and I'm struggling trying to think of how to approach the issue. My main issue is the whole image gallery side of it. In order to make it so that my client can take the site and not have *me* cre...
Try to keep the business logic out of the theme. Dealing with images is always an edge case, because they *do* affect presentation, which is usually a theme job. But the logic of how to get and order these images, the JavaScript parts and the backend are probably better in a separate code base. That is also easier for...
174,147
<p>Been struggling with this for a little while. I want to call a menu but include the title of the menu above the menu list. The basic code I have is as follows - </p> <pre><code>&lt;?php wp_nav_menu( array( 'container' =&gt; 'div', 'container_class' =&gt; 'rmm-footer', 'theme_location' =&gt; 'resources' )); ?...
[ { "answer_id": 174149, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 4, "selected": true, "text": "<p>You can not get the menu title using <code>wp_nav_menu()</code>, you need to get the menu object as follow:</p...
2015/01/07
[ "https://wordpress.stackexchange.com/questions/174147", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65641/" ]
Been struggling with this for a little while. I want to call a menu but include the title of the menu above the menu list. The basic code I have is as follows - ``` <?php wp_nav_menu( array( 'container' => 'div', 'container_class' => 'rmm-footer', 'theme_location' => 'resources' )); ?> ``` This produces a li...
You can not get the menu title using `wp_nav_menu()`, you need to get the menu object as follow: ``` //Change with the ID of your menu $menu_ID = 5; $nav_menu = wp_get_nav_menu_object( $menu_ID ); // then echo the name of the menu echo $nav_menu->name; ``` With the above code, you can insert the menu name in `wp_nav...
174,150
<p>I recently moved my WordPress network to a new domain and thought I had updated every reference to that domin, however I was wrong. I searched high and low for the answey, but alas I could find it no where, so I thought I'd write this question/answer.</p> <p>In my scanario, the 'home' site on the network is a simp...
[ { "answer_id": 174151, "author": "David Gard", "author_id": 10097, "author_profile": "https://wordpress.stackexchange.com/users/10097", "pm_score": 3, "selected": true, "text": "<h1>The database</h1>\n<p>Initially you should update all references to your old domain in the database. The ...
2015/01/07
[ "https://wordpress.stackexchange.com/questions/174150", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10097/" ]
I recently moved my WordPress network to a new domain and thought I had updated every reference to that domin, however I was wrong. I searched high and low for the answey, but alas I could find it no where, so I thought I'd write this question/answer. In my scanario, the 'home' site on the network is a simple page tha...
The database ============ Initially you should update all references to your old domain in the database. The following SQL will take care of that, but first read these notes - * This SQL assumes that you are using the default `wp_` table prefix. Simply change this to your chosen table prefix if you have changed it. *...
174,154
<p>I'm trying to build my own Wordpress theme using the correct ways. But...</p> <p>The first trouble that I found was how to add css and js "using the correct way".</p> <p>I found severals tutorials how to do it. e.x: <a href="http://code.tutsplus.com/tutorials/loading-css-into-wordpress-the-right-way--cms-20402" re...
[ { "answer_id": 174166, "author": "Varun Kumar", "author_id": 48415, "author_profile": "https://wordpress.stackexchange.com/users/48415", "pm_score": 3, "selected": true, "text": "<p>Pretty straightforward answer is both are the correct. In first method you are breaking down the process i...
2015/01/07
[ "https://wordpress.stackexchange.com/questions/174154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65640/" ]
I'm trying to build my own Wordpress theme using the correct ways. But... The first trouble that I found was how to add css and js "using the correct way". I found severals tutorials how to do it. e.x: <http://code.tutsplus.com/tutorials/loading-css-into-wordpress-the-right-way--cms-20402> *(this is from "30-Jun-2014...
Pretty straightforward answer is both are the correct. In first method you are breaking down the process in two steps. That is needed in case you want to register some scripts but want to load them conditionally at some later time. For example you may want to load some script only when some second script requires this ...