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
238,953
<p>I am trying to insert a small form into a WordPress page that does a minor calculation based on user input and returns an answer. Initially I tried copying the entire thing (HTML and JS (in a <code>&lt;script&gt;</code> tag) in the text editor), which displayed the HTML form fine, but trying to run the JS didn't wor...
[ { "answer_id": 238955, "author": "Aniruddha Gawade", "author_id": 101818, "author_profile": "https://wordpress.stackexchange.com/users/101818", "pm_score": -1, "selected": false, "text": "<p>Using jQuery:</p>\n\n<p>First debug and check if the function is getting called. Try <code>alert(...
2016/09/12
[ "https://wordpress.stackexchange.com/questions/238953", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86933/" ]
I am trying to insert a small form into a WordPress page that does a minor calculation based on user input and returns an answer. Initially I tried copying the entire thing (HTML and JS (in a `<script>` tag) in the text editor), which displayed the HTML form fine, but trying to run the JS didn't work. The JS looks lik...
You have a bunch of issues: 1. WordPress part: ================== Your function is hooked to [`wp_enqueue_scripts`](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts) and should be like this: ``` function wpse238953_calculate() { wp_enqueue_script('calculate', plugins_url('/js/calculat...
238,982
<p>I have two different instances of the same server (one for development, one for deployment), built independently but basically the same (same OS, same WordPress version, same content etc.).</p> <p>However, I'm confused about the configuration: it looks to me like they're configured the same (except that the deploym...
[ { "answer_id": 238990, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>On WP side the only handling it does is setting log to <code>WP_CONTENT_DIR . '/debug.log'</code> if <code>WP_DEBUG...
2016/09/12
[ "https://wordpress.stackexchange.com/questions/238982", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64675/" ]
I have two different instances of the same server (one for development, one for deployment), built independently but basically the same (same OS, same WordPress version, same content etc.). However, I'm confused about the configuration: it looks to me like they're configured the same (except that the deployment server...
As described elsewhere on this page, in my case the solution was simply to reset the value of PHP's `error_log` setting. I did this by adding to the end of my `/var/www/html/wp-config.php`: ``` ini_restore('error_log'); ``` One important point: I ended up putting this right at the end because it didn't seem to take ...
238,994
<p>I'm having a customer who wants a WordPress page, and I don't have the best overview of the plugins and possibilities for this exact requirement my customer wants.</p> <p>He arranges an seminar once a year, so for each year the site text and pictures look very different, but the main theme of the page stays the sam...
[ { "answer_id": 238990, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>On WP side the only handling it does is setting log to <code>WP_CONTENT_DIR . '/debug.log'</code> if <code>WP_DEBUG...
2016/09/12
[ "https://wordpress.stackexchange.com/questions/238994", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102661/" ]
I'm having a customer who wants a WordPress page, and I don't have the best overview of the plugins and possibilities for this exact requirement my customer wants. He arranges an seminar once a year, so for each year the site text and pictures look very different, but the main theme of the page stays the same. When th...
As described elsewhere on this page, in my case the solution was simply to reset the value of PHP's `error_log` setting. I did this by adding to the end of my `/var/www/html/wp-config.php`: ``` ini_restore('error_log'); ``` One important point: I ended up putting this right at the end because it didn't seem to take ...
239,006
<p>I need a stylesheet to be added to the header before anything else. That means before any styles or scripts that are automatically added by any of the plugins I'm also using.</p> <p>I figured I could add this stylesheet with wp_enqueue_script, but I'm not sure how to force it to be loaded before other stylesheets ...
[ { "answer_id": 239008, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 3, "selected": true, "text": "<p>The tag that you want to call to execute your function is the <a href=\"https://codex.wordpress.org/P...
2016/09/12
[ "https://wordpress.stackexchange.com/questions/239006", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24617/" ]
I need a stylesheet to be added to the header before anything else. That means before any styles or scripts that are automatically added by any of the plugins I'm also using. I figured I could add this stylesheet with wp\_enqueue\_script, but I'm not sure how to force it to be loaded before other stylesheets or script...
The tag that you want to call to execute your function is the [`wp_head()`](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head) with a priority of `1`. In your child theme's [`functions.php`](https://codex.wordpress.org/Child_Themes#Using_functions.php) file, add the following: ``` add_action( 'wp_head',...
239,042
<p>I'm currently using wp_list_pages to show site pages.</p> <p>It doesn't include private pages, so I need to find a way to produce a list of them too.</p> <p>I can do it with a plugin, but it includes various options I don't need and I prefer to hardcode something appropriate into a template.</p>
[ { "answer_id": 239008, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 3, "selected": true, "text": "<p>The tag that you want to call to execute your function is the <a href=\"https://codex.wordpress.org/P...
2016/09/13
[ "https://wordpress.stackexchange.com/questions/239042", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63350/" ]
I'm currently using wp\_list\_pages to show site pages. It doesn't include private pages, so I need to find a way to produce a list of them too. I can do it with a plugin, but it includes various options I don't need and I prefer to hardcode something appropriate into a template.
The tag that you want to call to execute your function is the [`wp_head()`](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head) with a priority of `1`. In your child theme's [`functions.php`](https://codex.wordpress.org/Child_Themes#Using_functions.php) file, add the following: ``` add_action( 'wp_head',...
239,044
<p>So I need to add additional fields in the wordpress tiny mce pop up</p> <p>My current Code</p> <pre><code>(function () { tinymce.PluginManager.add('aptmce_btn', function (editor, url) { editor.addButton('aptmce_btn', { text: 'Add popup', icon: false, onclick: function () { e...
[ { "answer_id": 239048, "author": "David Navia", "author_id": 92828, "author_profile": "https://wordpress.stackexchange.com/users/92828", "pm_score": 0, "selected": false, "text": "<p>I've been two days fighting this Tinymce just for make a simple data validation and found this good stuff...
2016/09/13
[ "https://wordpress.stackexchange.com/questions/239044", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/80397/" ]
So I need to add additional fields in the wordpress tiny mce pop up My current Code ``` (function () { tinymce.PluginManager.add('aptmce_btn', function (editor, url) { editor.addButton('aptmce_btn', { text: 'Add popup', icon: false, onclick: function () { editor.windowManager.o...
See here, I think it's enough for making any kind of TinyMCE Editor button with extended options like dropdown etc <https://www.gavick.com/blog/wordpress-tinymce-custom-buttons> Anyway if we came down to dropdown, checkbox and radio button on Popup, here is a demonstration. ``` (function () { tinymce.PluginManager.a...
239,071
<p>This <a href="https://wordpress.stackexchange.com/questions/4725/how-to-change-a-users-role/191433#191433">Stack response</a> explains how to change the role of a given user. Is there a way to execute that when the page loads?</p> <p>I run a language school and there are unique login destinations for Prospective, A...
[ { "answer_id": 239048, "author": "David Navia", "author_id": 92828, "author_profile": "https://wordpress.stackexchange.com/users/92828", "pm_score": 0, "selected": false, "text": "<p>I've been two days fighting this Tinymce just for make a simple data validation and found this good stuff...
2016/09/13
[ "https://wordpress.stackexchange.com/questions/239071", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96983/" ]
This [Stack response](https://wordpress.stackexchange.com/questions/4725/how-to-change-a-users-role/191433#191433) explains how to change the role of a given user. Is there a way to execute that when the page loads? I run a language school and there are unique login destinations for Prospective, Active and Inactive st...
See here, I think it's enough for making any kind of TinyMCE Editor button with extended options like dropdown etc <https://www.gavick.com/blog/wordpress-tinymce-custom-buttons> Anyway if we came down to dropdown, checkbox and radio button on Popup, here is a demonstration. ``` (function () { tinymce.PluginManager.a...
239,093
<p>I have got something like this:</p> <pre><code>$taxonomies = get_object_taxonomies('my_post_type'); foreach($taxonomies as $tax){ $args['labels'] = get_taxonomy_labels( (object) $args ); $args['label'] = $args['labels']-&gt;singular_name; echo $args['label']; } </code></pre> <p>which gives me “Tag” each t...
[ { "answer_id": 239097, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 3, "selected": true, "text": "<p><strong>EDIT</strong>\nSince I missunderstood your question at first, here's the update that should do what ...
2016/09/13
[ "https://wordpress.stackexchange.com/questions/239093", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/97280/" ]
I have got something like this: ``` $taxonomies = get_object_taxonomies('my_post_type'); foreach($taxonomies as $tax){ $args['labels'] = get_taxonomy_labels( (object) $args ); $args['label'] = $args['labels']->singular_name; echo $args['label']; } ``` which gives me “Tag” each time, for post\_tags but also ...
**EDIT** Since I missunderstood your question at first, here's the update that should do what you want. ``` $taxonomies = get_object_taxonomies( 'my_post_type', 'object' ); foreach($taxonomies as $tax){ echo $tax->labels->singular_name; } ``` Basically, you need to specify to the `get_object_taxonomies` functio...
239,095
<p>I have the registration workflow set so that my user have to fill out a gravity forms user registration form and then activate their account via a link in an email. The email link sends them to a page that tells the user whether their registration has been successful or a failure. Up on success, I would like my us...
[ { "answer_id": 239150, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>I am not sure what link are you trying to build and how it ties to specifics of Gravity Forms (questions about whic...
2016/09/13
[ "https://wordpress.stackexchange.com/questions/239095", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102710/" ]
I have the registration workflow set so that my user have to fill out a gravity forms user registration form and then activate their account via a link in an email. The email link sends them to a page that tells the user whether their registration has been successful or a failure. Up on success, I would like my users t...
After much research, I finally turned to examining the WordPress core file wp\_login.php hoping that WP would show how they do it in a non-obtuse manner. From the information around line 331 (WP 4.6.1), I put together the following code. ``` <?php global $gw_activate_template; extract( $gw_activate_template->result ...
239,127
<p>I'm working on a rather large and old Wordpress project where someone has previously used <code>query_posts</code> all over the place. For this reason, I'm unwilling to change those method calls. I'm not the maintainer of the site, I'm doing a quick fix.</p> <p>Each post in question has a field called <code>our_dat...
[ { "answer_id": 239138, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>Since both wordpress and laravel will most likely try to take control from each other. The best way to do...
2016/09/13
[ "https://wordpress.stackexchange.com/questions/239127", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102723/" ]
I'm working on a rather large and old Wordpress project where someone has previously used `query_posts` all over the place. For this reason, I'm unwilling to change those method calls. I'm not the maintainer of the site, I'm doing a quick fix. Each post in question has a field called `our_date`, which represents a dat...
There is no "generic" way to just smash WP with another app and have it work. It can be roughly split in two cases: 1. Applications run separately on server, installed in different directories, and styled to look as one site (possibly talking to same database, possibly talking to each other via REST API or something)...
239,141
<pre><code>echo do_shortcode('https://www.youtube.com/watch?v=vZBCTc9zHtI'); </code></pre> <p>Is merely printing </p> <pre><code>https://www.youtube.com/watch?v=vZBCTc9zHtI" </code></pre> <p>out onto the page.</p> <p>I know I can display the video with html with</p> <pre><code>&lt;iframe src="http://www.youtube.c...
[ { "answer_id": 239143, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": false, "text": "<p>If you just want to embed a video in the content area, WordPress does this pretty elegantly with <a href=\"...
2016/09/13
[ "https://wordpress.stackexchange.com/questions/239141", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13170/" ]
``` echo do_shortcode('https://www.youtube.com/watch?v=vZBCTc9zHtI'); ``` Is merely printing ``` https://www.youtube.com/watch?v=vZBCTc9zHtI" ``` out onto the page. I know I can display the video with html with ``` <iframe src="http://www.youtube.com/embed/vZBCTc9zHtI" width="560" height="315" frameborder="0" ...
I think this is what you are looking for: ``` <?php echo wp_oembed_get('https://www.youtube.com/watch?v=vZBCTc9zHtI'); ?> ``` For more details check this [documentation](https://codex.wordpress.org/Function_Reference/wp_oembed_get).
239,155
<p>Attention: It's <strong>order</strong>, not <strong>orderby</strong>.</p> <p>According to wordpress docs, there are only two options to <strong>order</strong>, which are ASC or DESC.</p> <h3>The problem is:</h3> <p>I would like to randomize <strong>the posts I've selected</strong>, not randomize <strong>WHICH posts ...
[ { "answer_id": 239158, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 3, "selected": true, "text": "<p>You are right that you can't have WordPress order the retrieved posts randomly. So you'll have to do that yoursel...
2016/09/13
[ "https://wordpress.stackexchange.com/questions/239155", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27278/" ]
Attention: It's **order**, not **orderby**. According to wordpress docs, there are only two options to **order**, which are ASC or DESC. ### The problem is: I would like to randomize **the posts I've selected**, not randomize **WHICH posts I select**. Here's my code for better explanation: ``` <?php return array( ...
You are right that you can't have WordPress order the retrieved posts randomly. So you'll have to do that yourself after you have retrieved the array of post objects. Let's call that `$my_posts`. Because you don't know how many of the posts in that array are featured, you will have to loop through them to split the ar...
239,170
<p>I'm making the following query in order to get all the posts sorted by a meta key (wpcf-estado in this case) but it returns the items in no order:</p> <pre><code>$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' =&gt; 'proyectos', ...
[ { "answer_id": 239158, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 3, "selected": true, "text": "<p>You are right that you can't have WordPress order the retrieved posts randomly. So you'll have to do that yoursel...
2016/09/13
[ "https://wordpress.stackexchange.com/questions/239170", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/90416/" ]
I'm making the following query in order to get all the posts sorted by a meta key (wpcf-estado in this case) but it returns the items in no order: ``` $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'proyectos', 'pos...
You are right that you can't have WordPress order the retrieved posts randomly. So you'll have to do that yourself after you have retrieved the array of post objects. Let's call that `$my_posts`. Because you don't know how many of the posts in that array are featured, you will have to loop through them to split the ar...
239,228
<p>I have a real estate theme with custom post: properties. Post has many meta values such as price and taxonomy such as location. I created search engine for this but queries take ridiculous amount of time to execute.</p> <p>I have only 50 properties in the database, but wp_postmeta table has 20044 rows.</p> <p>Samp...
[ { "answer_id": 239241, "author": "Xavi Ivars", "author_id": 6334, "author_profile": "https://wordpress.stackexchange.com/users/6334", "pm_score": 1, "selected": false, "text": "<p>That's a known problem with WordPress and searches involving postmeta.</p>\n\n<p>What I'd try to do is to cr...
2016/09/14
[ "https://wordpress.stackexchange.com/questions/239228", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102783/" ]
I have a real estate theme with custom post: properties. Post has many meta values such as price and taxonomy such as location. I created search engine for this but queries take ridiculous amount of time to execute. I have only 50 properties in the database, but wp\_postmeta table has 20044 rows. Sample query, that t...
That's a known problem with WordPress and searches involving postmeta. What I'd try to do is to create a new taxonomy for "things" you're usually searching the most: * `offer_order_status` seems the better candidate, as it can be active or not. I'd create a taxonomy with two elements. That would reduce the time of y...
239,243
<p>I've created a custom taxonomy, for a custom post type, and created a custom page for it, the usual, etc.</p> <p>Problem is I want to only show the custom posts that are part of the category, and not show the posts from the sub categories. So I wrote the following query for the loop:</p> <pre><code>&lt;?php global...
[ { "answer_id": 239470, "author": "hkchakladar", "author_id": 65568, "author_profile": "https://wordpress.stackexchange.com/users/65568", "pm_score": 1, "selected": false, "text": "<p>Try this:</p>\n\n<ol>\n<li>As @gdaniel said, you are giving a string in place of boolean value.\nReplace ...
2016/09/14
[ "https://wordpress.stackexchange.com/questions/239243", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56659/" ]
I've created a custom taxonomy, for a custom post type, and created a custom page for it, the usual, etc. Problem is I want to only show the custom posts that are part of the category, and not show the posts from the sub categories. So I wrote the following query for the loop: ``` <?php global $wp_query; $args = arra...
Try this: 1. As @gdaniel said, you are giving a string in place of boolean value. Replace `'include_children' => 'false'` to `'include_children' => false` (Remove quote from `false`) 2. You can hook into the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) to change the query var...
239,252
<p>I'm trying to add a custom field to a post title (<a href="https://www.horizonhomes-samui.com/properties/hs0525-chaweng-noi-4-bedroom-coastal-front-villa/" rel="nofollow noreferrer">sample page</a>). To do so, I'm following the instructions given in <a href="https://wordpress.stackexchange.com/questions/224340/how-...
[ { "answer_id": 239259, "author": "hkchakladar", "author_id": 65568, "author_profile": "https://wordpress.stackexchange.com/users/65568", "pm_score": 2, "selected": false, "text": "<p>I assume that you want to use <code>propertysq</code> custom field/post meta in the title and you use Yoa...
2016/09/14
[ "https://wordpress.stackexchange.com/questions/239252", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51204/" ]
I'm trying to add a custom field to a post title ([sample page](https://www.horizonhomes-samui.com/properties/hs0525-chaweng-noi-4-bedroom-coastal-front-villa/)). To do so, I'm following the instructions given in [this previous question](https://wordpress.stackexchange.com/questions/224340/how-to-use-custom-fields-in-p...
I assume that you want to use `propertysq` custom field/post meta in the title and you use Yoast SEO. ( Correct me if I'm wrong ) So, use this is your `functions.php` ``` function wpse239252_hook_title($title) { global $post; // make sure the post object is available to us if(is_singular()){ // check we're on a singl...
239,255
<p>My wp-options keeps crashing and am getting "error establishing a database connecting" when I try loading the page. I don't know whats causing this to happen, I read somewhere that I might need more ram so i upgraded my plan to get 2GB of ram 40GB of space. But today it crashed again, I repaired it and went to the e...
[ { "answer_id": 239260, "author": "user6736476", "author_id": 102798, "author_profile": "https://wordpress.stackexchange.com/users/102798", "pm_score": 0, "selected": false, "text": "<p>I have find out that you can run cron job to automatically repair and optimize the database for you. By...
2016/09/14
[ "https://wordpress.stackexchange.com/questions/239255", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102798/" ]
My wp-options keeps crashing and am getting "error establishing a database connecting" when I try loading the page. I don't know whats causing this to happen, I read somewhere that I might need more ram so i upgraded my plan to get 2GB of ram 40GB of space. But today it crashed again, I repaired it and went to the erro...
It sounds like you may be running a plugin that stores too many transient options. If you can't currently access wp-admin, try FTP'ing in and renaming your /plugins folder to disable all plugins. Then you should be able to log in to wp-admin. Next, back in FTP rename your /plugins folder back to the normal /plugins, an...
239,258
<p>I logged out from wordpress site then,</p> <p>I edited <code>wp-config.php</code> </p> <p>and enabled <code>SSL</code></p> <pre><code>define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true); </code></pre> <p>then restarted apache</p> <p>but on trying to open I got the is</p> <blockquote> <p>Not Foun...
[ { "answer_id": 239273, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 0, "selected": false, "text": "<p>It sounds like you haven't updated the Site URL and Home settings. There are 2 ways to do this:</p>\n\n<o...
2016/09/14
[ "https://wordpress.stackexchange.com/questions/239258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102804/" ]
I logged out from wordpress site then, I edited `wp-config.php` and enabled `SSL` ``` define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true); ``` then restarted apache but on trying to open I got the is > > Not Found > > > The requested URL /wp-login.php was not found on this server. > > >
As per OP's comment: > > *Yes, I have self signed using OpenSSL, now I have the site opening on HTTPS but in browser it still says connection not secure where it is showing HTTPS in the address bar.* > > > In that case, it sounds like some links are being called through HTTP while other are being called on HTTPS,...
239,292
<p>I'm new to WordPress and I'm still learning from tutorials, but I'm confused with their conflicted ways. What the difference between these two ways to make the title a link:</p> <pre><code>&lt;h1&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;"&gt; &lt;?php the_title(); ?&gt; &lt;/a&gt; &lt;/h1&gt; </co...
[ { "answer_id": 239295, "author": "vancoder", "author_id": 26778, "author_profile": "https://wordpress.stackexchange.com/users/26778", "pm_score": 0, "selected": false, "text": "<p>There are multiple ways to do most things in WordPress. Either that, or there are no ways at all.</p>\n\n<p>...
2016/09/14
[ "https://wordpress.stackexchange.com/questions/239292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102827/" ]
I'm new to WordPress and I'm still learning from tutorials, but I'm confused with their conflicted ways. What the difference between these two ways to make the title a link: ``` <h1> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a> </h1> ``` and ``` <?php the_title(sprintf( '<...
The second form can be handy too: * We can also use the [third](https://developer.wordpress.org/reference/functions/the_title/) parameter: ``` the_title( $before, $after, $echo ); ``` to assign the title to a variable. Here's an example: ``` $title = the_title( '<h1 class="entry-title">', '</h1>', false ); ```...
239,302
<p>Some plugins place various links under their name on the primary column on the plugin page. So we end up with something like:</p> <pre><code>Home Page | Support Forums | Documentation | Upgrade to Pro Edition | Donate | Settings | Activate | Delete </code></pre> <p>In an effort to keep just the standard links <code>...
[ { "answer_id": 241011, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 3, "selected": true, "text": "<p>You have the right approach. You will want to use the <a href=\"https://codex.wordpress.org/Plugin_AP...
2016/09/14
[ "https://wordpress.stackexchange.com/questions/239302", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17797/" ]
Some plugins place various links under their name on the primary column on the plugin page. So we end up with something like: ``` Home Page | Support Forums | Documentation | Upgrade to Pro Edition | Donate | Settings | Activate | Delete ``` In an effort to keep just the standard links `Settings | Activate | Delete`...
You have the right approach. You will want to use the [`admin_enqueue_scripts`](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts) hook: ``` add_action( 'admin_enqueue_scripts', 'wpse_239302_hide_action_links' ); function wpse_239302_hide_action_links() { global $pagenow; if ( $pag...
239,359
<p>I have a page where I want to show Blog Posts on a monthly basis. And I want to show the post of the previous month if the current month has no posts. Something like the image given below. It is showing the posts of August because September has no post. <a href="https://i.stack.imgur.com/PrWRY.jpg" rel="nofollow nor...
[ { "answer_id": 239362, "author": "sdexp", "author_id": 102830, "author_profile": "https://wordpress.stackexchange.com/users/102830", "pm_score": 1, "selected": false, "text": "<p>I have this code which does something similar but it's only counting posts. If you grab the required info in ...
2016/09/15
[ "https://wordpress.stackexchange.com/questions/239359", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102530/" ]
I have a page where I want to show Blog Posts on a monthly basis. And I want to show the post of the previous month if the current month has no posts. Something like the image given below. It is showing the posts of August because September has no post. [![enter image description here](https://i.stack.imgur.com/PrWRY.j...
First, get the current month and year: ``` $month = int(current_time('m')); $year = int(current_time('Y')); ``` Next, get the posts in this month: ``` $query = new WP_Query( 'year=' . $year . '&monthnum=' . $month ); ``` If the query returns empty query the month before and repeat this until you have found a non ...
239,376
<p>Thanks in advance for any pointers in the right direction. I am not finding any relevant info out there.</p> <p>I have a finished WP site with a customized Bones Theme functioning perfectly locally. I have uploaded it many times and in many variations. The customized theme is recognized by its name and activated. T...
[ { "answer_id": 239362, "author": "sdexp", "author_id": 102830, "author_profile": "https://wordpress.stackexchange.com/users/102830", "pm_score": 1, "selected": false, "text": "<p>I have this code which does something similar but it's only counting posts. If you grab the required info in ...
2016/09/15
[ "https://wordpress.stackexchange.com/questions/239376", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102862/" ]
Thanks in advance for any pointers in the right direction. I am not finding any relevant info out there. I have a finished WP site with a customized Bones Theme functioning perfectly locally. I have uploaded it many times and in many variations. The customized theme is recognized by its name and activated. The backgro...
First, get the current month and year: ``` $month = int(current_time('m')); $year = int(current_time('Y')); ``` Next, get the posts in this month: ``` $query = new WP_Query( 'year=' . $year . '&monthnum=' . $month ); ``` If the query returns empty query the month before and repeat this until you have found a non ...
239,392
<p>I'm trying to use WP Crontrol to run a cron job that executes 2 URLS:</p> <p>Cron job 1: exampleurl.com - once every 2 minutes Cron job 2: exampleurl2.com - once every 24 hours</p> <p>How can I right a function to do this that I can execute via the hook name using WP Crontrol?</p> <p>Thanks,</p>
[ { "answer_id": 239398, "author": "luukvhoudt", "author_id": 44637, "author_profile": "https://wordpress.stackexchange.com/users/44637", "pm_score": 0, "selected": false, "text": "<p>To answer your question, slightly incorrect. You can also use <a href=\"https://codex.wordpress.org/Functi...
2016/09/15
[ "https://wordpress.stackexchange.com/questions/239392", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102370/" ]
I'm trying to use WP Crontrol to run a cron job that executes 2 URLS: Cron job 1: exampleurl.com - once every 2 minutes Cron job 2: exampleurl2.com - once every 24 hours How can I right a function to do this that I can execute via the hook name using WP Crontrol? Thanks,
AS said by Fleuv you can use wp\_schedule\_event() function to execute your code like this ``` add_action('my_twfours_action', 'my_twfours_action_fn'); my_twfours_action_fn (){ //this code will execute every 24 hours } wp_schedule_event( time(), 'daily', 'my_twfours_action' ); //adding new cron schedule event ``` T...
239,394
<p>Just installed an existing WordPress on my localhost (<a href="https://www.mamp.info/en/" rel="nofollow">MAMP</a>) to check for a few images issues.</p> <p>However, when I visit:</p> <pre><code>localhost:8888/wordpress/ </code></pre> <p>I'm redirected to:</p> <pre><code>localhost/wordpress/ </code></pre> <p>Whi...
[ { "answer_id": 239397, "author": "luukvhoudt", "author_id": 44637, "author_profile": "https://wordpress.stackexchange.com/users/44637", "pm_score": 0, "selected": false, "text": "<p>Wordpress defines a static value for the site url after installation. This data is stored in the database....
2016/09/15
[ "https://wordpress.stackexchange.com/questions/239394", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102883/" ]
Just installed an existing WordPress on my localhost ([MAMP](https://www.mamp.info/en/)) to check for a few images issues. However, when I visit: ``` localhost:8888/wordpress/ ``` I'm redirected to: ``` localhost/wordpress/ ``` Which is not the path to my files anymore. I've checked for any possible redirection...
There are a few variables that need to be changed in order for you to update to the new link on your WordPress site since you mention that you've installed an existing WordPress site that has already been set up. Try the following steps using the Search Replace DB tool: 1. Go and download [Interconnect IT's Database ...
239,401
<p>I understand that when using <code>get_template_part('content', get_post_format());</code> it will help choosing a <code>post format</code> for specific page according to post format.</p> <p>And if there is no post format 'i.e it's standard', then it will fallback to <code>content.php</code></p> <p>But what if I u...
[ { "answer_id": 262652, "author": "Vishal Kumar Sahu", "author_id": 101300, "author_profile": "https://wordpress.stackexchange.com/users/101300", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>You could get by with only the one template (content.php). That's\n usually less...
2016/09/15
[ "https://wordpress.stackexchange.com/questions/239401", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102827/" ]
I understand that when using `get_template_part('content', get_post_format());` it will help choosing a `post format` for specific page according to post format. And if there is no post format 'i.e it's standard', then it will fallback to `content.php` But what if I used `content-single.php` with some logic like this...
No, `content.php` and `content-single.php` are not the same thing. In your example CODE: ``` if (get_post_format() == false) { get_template_part('content', 'single'); } else { get_template_part('content', get_post_format()); } ``` WordPress will load `content-single.php` when `get_post_format()` is `false`....
239,402
<p>I need to create php file like <strong>download.php</strong>.</p> <p>In this file download links for movie or program,</p> <p>when users click on download button, this file <strong>download.php</strong> load in fancybox and display download links.</p> <p><a href="http://sitename/template_path/download.php?post_i...
[ { "answer_id": 262652, "author": "Vishal Kumar Sahu", "author_id": 101300, "author_profile": "https://wordpress.stackexchange.com/users/101300", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>You could get by with only the one template (content.php). That's\n usually less...
2016/09/15
[ "https://wordpress.stackexchange.com/questions/239402", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98853/" ]
I need to create php file like **download.php**. In this file download links for movie or program, when users click on download button, this file **download.php** load in fancybox and display download links. <http://sitename/template_path/download.php?post_id=post_id>
No, `content.php` and `content-single.php` are not the same thing. In your example CODE: ``` if (get_post_format() == false) { get_template_part('content', 'single'); } else { get_template_part('content', get_post_format()); } ``` WordPress will load `content-single.php` when `get_post_format()` is `false`....
239,421
<p>The output of the settings API's function <code>add_settings_field()</code> is this:</p> <pre><code>&lt;tr&gt; &lt;th scope="row"&gt;Your title&lt;/th&gt; &lt;td&gt; Your field output &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>I know I can't change the way it's output, but I was wondering if there is a way I can p...
[ { "answer_id": 239435, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 2, "selected": false, "text": "<p>You can hide it using jQuery which will be inserted in the <code>wp-admin</code> header:</p>\n\n<pre...
2016/09/15
[ "https://wordpress.stackexchange.com/questions/239421", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102898/" ]
The output of the settings API's function `add_settings_field()` is this: ``` <tr> <th scope="row">Your title</th> <td> Your field output </td> </tr> ``` I know I can't change the way it's output, but I was wondering if there is a way I can put a `display:none;` on the `<tr>` with PHP? I don't want to do it with J...
You can hide it using jQuery which will be inserted in the `wp-admin` header: ``` add_action( 'admin_head', 'wpse_239421_hide_section' ); function wpse_239421_hide_section() { ?> <script type="text/javascript"> jQuery(document).ready(function($) { $('[scope=row]').closest('tr').hide(); ...
239,423
<p>I'm trying to format the list produced by <code>wp_nav_menu()</code> so that within each <code>&lt;li&gt;</code> is a <code>&lt;span&gt;</code> that wraps the text. At first I thought I could accomplish this using the the <code>items_wrap</code> argument, but that changes only the enclosing <code>&lt;ul&gt;</code>, ...
[ { "answer_id": 239435, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 2, "selected": false, "text": "<p>You can hide it using jQuery which will be inserted in the <code>wp-admin</code> header:</p>\n\n<pre...
2016/09/15
[ "https://wordpress.stackexchange.com/questions/239423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102900/" ]
I'm trying to format the list produced by `wp_nav_menu()` so that within each `<li>` is a `<span>` that wraps the text. At first I thought I could accomplish this using the the `items_wrap` argument, but that changes only the enclosing `<ul>`, correct? This seems like it should be simple enough to accomplish. Thanks!
You can hide it using jQuery which will be inserted in the `wp-admin` header: ``` add_action( 'admin_head', 'wpse_239421_hide_section' ); function wpse_239421_hide_section() { ?> <script type="text/javascript"> jQuery(document).ready(function($) { $('[scope=row]').closest('tr').hide(); ...
239,452
<p>I've been working with embeded content and as many already know, wordpress wraps the_content() lines in p tags.</p> <p>So, found this:</p> <pre><code>$content = preg_replace('/&lt;p&gt;\s*(&lt;img .* \/&gt;)\s*(&lt;\/a&gt;)?\s*&lt;\/p&gt;/iU', '\1\2\3', $content); return preg_replace('/&lt;p&gt;\s*(&lt;iframe .*&g...
[ { "answer_id": 239457, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 3, "selected": true, "text": "<p>This should do it and also remove <code>&lt;p&gt;</code> tags from images that are linked.</p>\n\n<p>Why it remo...
2016/09/16
[ "https://wordpress.stackexchange.com/questions/239452", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101510/" ]
I've been working with embeded content and as many already know, wordpress wraps the\_content() lines in p tags. So, found this: ``` $content = preg_replace('/<p>\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); return preg_replace('/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU', '\1', $content); ``` When...
This should do it and also remove `<p>` tags from images that are linked. Why it removes it from only one `<script>` instance is hard to tell. Would have to see your website code to investigate further. ``` // Remove p tags from images, scripts, and iframes. function remove_some_ptags( $content ) { $content = preg_...
239,475
<p>I'm attempting to order posts by meta data, which is working fine, but the posts without the meta are not shown.</p> <p>I've tried a couple of guides on Stack Exchange that come up with a quick Google, of which people say they work fine, but adding to my site, the code just does not want to show posts without the m...
[ { "answer_id": 239457, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 3, "selected": true, "text": "<p>This should do it and also remove <code>&lt;p&gt;</code> tags from images that are linked.</p>\n\n<p>Why it remo...
2016/09/16
[ "https://wordpress.stackexchange.com/questions/239475", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52020/" ]
I'm attempting to order posts by meta data, which is working fine, but the posts without the meta are not shown. I've tried a couple of guides on Stack Exchange that come up with a quick Google, of which people say they work fine, but adding to my site, the code just does not want to show posts without the meta data. ...
This should do it and also remove `<p>` tags from images that are linked. Why it removes it from only one `<script>` instance is hard to tell. Would have to see your website code to investigate further. ``` // Remove p tags from images, scripts, and iframes. function remove_some_ptags( $content ) { $content = preg_...
239,491
<p>I have website for local restaurant and for menu there are separate pages (ex: salads, soups etc). Right now the second restaurant was opened and it has a separate menu. </p> <p>What I want to do is to create some kind of switch - so user can select what restaurant he wants to see. And he can switch deserts page of...
[ { "answer_id": 239499, "author": "Pim", "author_id": 50432, "author_profile": "https://wordpress.stackexchange.com/users/50432", "pm_score": 2, "selected": false, "text": "<p>If you do this with pages, you will either have to make two pages, or you can put it in the same page and only sh...
2016/09/16
[ "https://wordpress.stackexchange.com/questions/239491", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16650/" ]
I have website for local restaurant and for menu there are separate pages (ex: salads, soups etc). Right now the second restaurant was opened and it has a separate menu. What I want to do is to create some kind of switch - so user can select what restaurant he wants to see. And he can switch deserts page of restauran...
If you do this with pages, you will either have to make two pages, or you can put it in the same page and only show the content of restaurant B when you click a button or link (for instance). This can be done with jQuery, for example. In the latter case you will have the same URL for the page. There are many ways to ...
239,501
<p>When I use:</p> <pre><code>define('WP_DEBUG', 1); </code></pre> <p>In my <code>wp-config.php</code>, it works fine, but I am hacking an old theme and I would like to suppress <em>deprecated</em> notices.</p> <p>My understanding is that adding this:</p> <pre><code>error_reporting( E_ERROR | E_NOTICE | E_PARSE ) </cod...
[ { "answer_id": 239517, "author": "Ethan O'Sullivan", "author_id": 98212, "author_profile": "https://wordpress.stackexchange.com/users/98212", "pm_score": 3, "selected": false, "text": "<p>As <a href=\"https://wordpress.stackexchange.com/users/74311/mmm\">mmm</a> stated:</p>\n\n<blockquot...
2016/09/16
[ "https://wordpress.stackexchange.com/questions/239501", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57686/" ]
When I use: ``` define('WP_DEBUG', 1); ``` In my `wp-config.php`, it works fine, but I am hacking an old theme and I would like to suppress *deprecated* notices. My understanding is that adding this: ``` error_reporting( E_ERROR | E_NOTICE | E_PARSE ) ``` Should do the trick. I have added it to `wp-config.php` a...
As [mmm](https://wordpress.stackexchange.com/users/74311/mmm) stated: > > *in which file appears the first notice?* > > > Wherever the notice is mentioning the location of this deprecated function (`path/to/some/file.php`), you would insert the following just below the `<?php` tag which starts off the file: ``` ...
239,514
<p>I have my WP put under</p> <pre><code>/wp </code></pre> <p>and then my-blog (which is an category, with the slug name 'my-blog') is set to access from (via the plugin 'Top level category')</p> <pre><code>/my-blog/ </code></pre> <p>everything seems fine, except my date-archives goes directly under the root as</p>...
[ { "answer_id": 239516, "author": "Jesper Nilsson", "author_id": 102950, "author_profile": "https://wordpress.stackexchange.com/users/102950", "pm_score": 2, "selected": true, "text": "<p>Thats posible by using Custom Structure of the permalinks like below:</p>\n\n<pre><code>/%category%/%...
2016/09/16
[ "https://wordpress.stackexchange.com/questions/239514", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102954/" ]
I have my WP put under ``` /wp ``` and then my-blog (which is an category, with the slug name 'my-blog') is set to access from (via the plugin 'Top level category') ``` /my-blog/ ``` everything seems fine, except my date-archives goes directly under the root as ``` /2016/09/ ``` which is the default permalink....
Thats posible by using Custom Structure of the permalinks like below: ``` /%category%/%year%/%monthnum%/%postname%/ ``` You will also be able to get a monthly archive of the category by going to: ``` /%category%/%year%/%monthnum%/ ``` like: ``` www.yoursite.com/my-blog/2016/09/ ```
239,520
<p>I am trying to insert content into a term's <code>description</code> field on save. </p> <pre><code>// insert stuff into description field of taxonomy function insert_taxonomy_content( $term_id, $tt_id, $taxonomy ){ // only insert content on certain taxonomies if ( $taxonomy === 'some_custom_taxonomy' ){ ...
[ { "answer_id": 239521, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"https://developer.wordpress.org/reference/hooks/edit_term/\" rel=\"nofollow\"><code>edit_term</cod...
2016/09/16
[ "https://wordpress.stackexchange.com/questions/239520", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10595/" ]
I am trying to insert content into a term's `description` field on save. ``` // insert stuff into description field of taxonomy function insert_taxonomy_content( $term_id, $tt_id, $taxonomy ){ // only insert content on certain taxonomies if ( $taxonomy === 'some_custom_taxonomy' ){ // unhook this fu...
So, thanks to cjbj I finally found the correct answer! I needed to use [`edited_term`](https://developer.wordpress.org/reference/hooks/edited_term/) instead of `edit_term`. Very subtle difference. `edited_term` fires after a term has been saved. ``` // insert stuff into description field of taxonomy function insert_t...
239,528
<p>I'm currently listing WordPress pages and child pages on a side widget using the following code. </p> <pre><code>&lt;ul class="side-links"&gt; &lt;?php wp_list_pages( array( 'title_li' =&gt; '' ) ); ?&gt; &lt;/ul&gt; </code></pre> <p>This lists all of my WordPress pages, if I add the following code<...
[ { "answer_id": 239521, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"https://developer.wordpress.org/reference/hooks/edit_term/\" rel=\"nofollow\"><code>edit_term</cod...
2016/09/16
[ "https://wordpress.stackexchange.com/questions/239528", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33866/" ]
I'm currently listing WordPress pages and child pages on a side widget using the following code. ``` <ul class="side-links"> <?php wp_list_pages( array( 'title_li' => '' ) ); ?> </ul> ``` This lists all of my WordPress pages, if I add the following code `'child_of' => $id` into the array I get the...
So, thanks to cjbj I finally found the correct answer! I needed to use [`edited_term`](https://developer.wordpress.org/reference/hooks/edited_term/) instead of `edit_term`. Very subtle difference. `edited_term` fires after a term has been saved. ``` // insert stuff into description field of taxonomy function insert_t...
239,549
<p>I want your help as I am new in Ajax and Wordpress. This is a simple plugin and I want to know what I am doing wrong and getting "zero" result</p> <blockquote> <p>ajax.php</p> </blockquote> <pre><code> add_shortcode( 'ajax_shortcode', 'ajax_shortcode_function' ); function ajax_shortcode_function() { wp_e...
[ { "answer_id": 239550, "author": "Nick P.", "author_id": 57671, "author_profile": "https://wordpress.stackexchange.com/users/57671", "pm_score": 0, "selected": false, "text": "<p>I just saw that in <code>wp_register_script</code> i have </p>\n\n<pre><code>plugins_url( '/ajax.js', __FILE_...
2016/09/17
[ "https://wordpress.stackexchange.com/questions/239549", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57671/" ]
I want your help as I am new in Ajax and Wordpress. This is a simple plugin and I want to know what I am doing wrong and getting "zero" result > > ajax.php > > > ``` add_shortcode( 'ajax_shortcode', 'ajax_shortcode_function' ); function ajax_shortcode_function() { wp_enqueue_script('jquery'); wp_regist...
It looks odd to me that your `ajax_shortcode_function()` registers and enqueues your ajax script. According to the [codex](https://codex.wordpress.org/AJAX_in_Plugins), you should register/enqueue in functions.php. Additionally, if you only need the url to ajax-admin.php, the tutorial says you can use the global `ajaxu...
239,584
<p>What is the difference between following two codes? (Directly call a function and call a function using add_action)</p> <pre><code>function pp_submit__link_form(){ if(isset( $_POST['action']) &amp;&amp; $_POST['action']="submit_link" ){ echo "Hello"; } } add_action( 'init', 'pp_submit__lin...
[ { "answer_id": 239560, "author": "Por", "author_id": 31832, "author_profile": "https://wordpress.stackexchange.com/users/31832", "pm_score": 0, "selected": false, "text": "<p>For clients website, after you have setup everything, you could upload to your hosting or client's one. But, if y...
2016/09/17
[ "https://wordpress.stackexchange.com/questions/239584", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102125/" ]
What is the difference between following two codes? (Directly call a function and call a function using add\_action) ``` function pp_submit__link_form(){ if(isset( $_POST['action']) && $_POST['action']="submit_link" ){ echo "Hello"; } } add_action( 'init', 'pp_submit__link_form' ); ``` --- ...
Congrats on your first client. I'm glad you are looking around to make sure that you start off on the right foot. Like anything that you start in life, your experience will increase over time and the more you practice. However, we live in a digital age and popular open-source platforms such as WordPress have great tut...
239,608
<p>I'm trying to add a custom menu structure for my WordPress theme. This is how I want it to look:</p> <pre><code>&lt;li&gt; &lt;a href="link_to_parent_item" class="main-category" tabindex="3"&gt;Parent Name&lt;/a&gt; &lt;div class="sub-menu"&gt; &lt;div class="sub-links pull-left"&gt; &lt...
[ { "answer_id": 239618, "author": "EBennett", "author_id": 91050, "author_profile": "https://wordpress.stackexchange.com/users/91050", "pm_score": 1, "selected": false, "text": "<p>It appears the</p>\n\n<pre><code>&lt;li&gt;&lt;/li&gt;\n</code></pre>\n\n<p>in the end_lvl function and also...
2016/09/17
[ "https://wordpress.stackexchange.com/questions/239608", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84265/" ]
I'm trying to add a custom menu structure for my WordPress theme. This is how I want it to look: ``` <li> <a href="link_to_parent_item" class="main-category" tabindex="3">Parent Name</a> <div class="sub-menu"> <div class="sub-links pull-left"> <a href="link_to_child_item">Child Name1</a> ...
Old question, but you can override the `</li>` in the Walker's `end_el()` function (see wp-includes/class-walker-nav-menu.php); in your case, something like: ``` public function end_el( &$output, $item, $depth = 0, $args = array() ) { if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { ...
239,650
<p>I'm new to WP, but have used other CMSs in the past.</p> <p>I wanted to make a simple Woo-commerce store, for practice. I installed WP, Woo-commerce and the Woo-commerce Store Front theme and all went fine.</p> <p>Now I want to start customising the theme. First thing I wanted to change was put a new logo in the h...
[ { "answer_id": 239652, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 3, "selected": true, "text": "<p>Looking at the current version of Storefront's <code>header.php</code>:</p>\n\n<pre><code>/**\n * Functions ...
2016/09/18
[ "https://wordpress.stackexchange.com/questions/239650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44964/" ]
I'm new to WP, but have used other CMSs in the past. I wanted to make a simple Woo-commerce store, for practice. I installed WP, Woo-commerce and the Woo-commerce Store Front theme and all went fine. Now I want to start customising the theme. First thing I wanted to change was put a new logo in the header. I opened h...
Looking at the current version of Storefront's `header.php`: ``` /** * Functions hooked into storefront_header action * * @hooked storefront_skip_links - 0 * @hooked storefront_social_icons - 10 * @hooked storefront_site_branding - 20 * @hooked storefr...
239,663
<p>I have a WordPress site that uses the WPRO (WordPress Read Only) plugin to host all media files on Amazon S3. I've changed the thumbnail and image sizes in my custom theme, and uploading new images to the media library uses the new sizes. However, when I try to regenerate all thumbnails using "Regenerate Thumbnails,...
[ { "answer_id": 239652, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 3, "selected": true, "text": "<p>Looking at the current version of Storefront's <code>header.php</code>:</p>\n\n<pre><code>/**\n * Functions ...
2016/09/18
[ "https://wordpress.stackexchange.com/questions/239663", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99435/" ]
I have a WordPress site that uses the WPRO (WordPress Read Only) plugin to host all media files on Amazon S3. I've changed the thumbnail and image sizes in my custom theme, and uploading new images to the media library uses the new sizes. However, when I try to regenerate all thumbnails using "Regenerate Thumbnails," i...
Looking at the current version of Storefront's `header.php`: ``` /** * Functions hooked into storefront_header action * * @hooked storefront_skip_links - 0 * @hooked storefront_social_icons - 10 * @hooked storefront_site_branding - 20 * @hooked storefr...
239,684
<p>I've alreday done lots of R&amp;D on this question but not get a suitable answer any where. This is very little task for me if , I need to make a mysql query. But though , I' not good hand on experience in WP so getting much frustrated by the solution of question.</p> <p><strong>How to sort a wp_query by custom col...
[ { "answer_id": 239689, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 0, "selected": false, "text": "<p>You told it to order by meta_value, so it's ordering by the meta value. There is no \"post_priority\" column in th...
2016/09/18
[ "https://wordpress.stackexchange.com/questions/239684", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103056/" ]
I've alreday done lots of R&D on this question but not get a suitable answer any where. This is very little task for me if , I need to make a mysql query. But though , I' not good hand on experience in WP so getting much frustrated by the solution of question. **How to sort a wp\_query by custom column that I added in...
I've investigated a bit and your problem is the `WP_Query::parse_orderby()` function. Everything you like to use as an order is sanitized there which the user Otto liked to point out. Unfortunately it has no filter to hook in. And yes it is better to use some meta\_fields if you can afford an expensive JOIN in every ge...
239,686
<p>I know this may be a duplicate however I haven't been able to make sense of previous questions.</p> <p>I have a checkbox on a settings page. Everything is okay on the first load of the page, if I check the box and save all is fine. If I then uncheck i get the following error:</p> <blockquote> <p><strong>Notice</...
[ { "answer_id": 239688, "author": "Ben H", "author_id": 64567, "author_profile": "https://wordpress.stackexchange.com/users/64567", "pm_score": 3, "selected": true, "text": "<p>Managed to fix this by doing the following:</p>\n\n<pre><code>function dat_checkbox_field_0_render( ) { \n\n ...
2016/09/18
[ "https://wordpress.stackexchange.com/questions/239686", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64567/" ]
I know this may be a duplicate however I haven't been able to make sense of previous questions. I have a checkbox on a settings page. Everything is okay on the first load of the page, if I check the box and save all is fine. If I then uncheck i get the following error: > > **Notice**: Undefined index: `dat_checkbox_...
Managed to fix this by doing the following: ``` function dat_checkbox_field_0_render( ) { $options = get_option( 'dat_settings' ); $a = $options; if (array_key_exists("dat_checkbox_field_0",$a)) { } else { $options['data_checkbox_field_0'] = false; } ?> <input type='checkbox' name='dat_se...
239,744
<p>I don't really understand how I can use the new responsive images feature that WordPress provides in my themes.</p> <p>Example:</p> <p>In my theme, I add a header-image. I therefore use the custom-header-image from customizer OR the post-thumbnail:</p> <pre><code>&lt;figure id="header-image" class="uk-margin-remo...
[ { "answer_id": 239751, "author": "Malisa", "author_id": 71627, "author_profile": "https://wordpress.stackexchange.com/users/71627", "pm_score": 0, "selected": false, "text": "<p>You could use an <a href=\"https://developer.wordpress.org/reference/functions/wp_get_attachment_image/\" rel=...
2016/09/19
[ "https://wordpress.stackexchange.com/questions/239744", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102493/" ]
I don't really understand how I can use the new responsive images feature that WordPress provides in my themes. Example: In my theme, I add a header-image. I therefore use the custom-header-image from customizer OR the post-thumbnail: ``` <figure id="header-image" class="uk-margin-remove"> <?php if ( ( is_single() |...
Following our exchange in the comments I've reread your question and have a pretty straightforward answer: It looks like it's working fine. You are worried about the `sizes` attribute in your second example, but it's the `srcset` attribute that you should look at and it *is* showing all of your image sizes: ``` <img...
239,748
<p>The URL I am hitting is:</p> <pre><code>home_url('18/profile') </code></pre> <p>I want URL to be executed as:</p> <pre><code>localhost/wordpress/seller?page=profile </code></pre> <p>18 is the page ID for seller page.</p> <p>Also, when I hit on above said URL multiple time then last part of URL appending continu...
[ { "answer_id": 239751, "author": "Malisa", "author_id": 71627, "author_profile": "https://wordpress.stackexchange.com/users/71627", "pm_score": 0, "selected": false, "text": "<p>You could use an <a href=\"https://developer.wordpress.org/reference/functions/wp_get_attachment_image/\" rel=...
2016/09/19
[ "https://wordpress.stackexchange.com/questions/239748", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103095/" ]
The URL I am hitting is: ``` home_url('18/profile') ``` I want URL to be executed as: ``` localhost/wordpress/seller?page=profile ``` 18 is the page ID for seller page. Also, when I hit on above said URL multiple time then last part of URL appending continuously. ``` add_filter( 'rewrite_rules_array','my_inser...
Following our exchange in the comments I've reread your question and have a pretty straightforward answer: It looks like it's working fine. You are worried about the `sizes` attribute in your second example, but it's the `srcset` attribute that you should look at and it *is* showing all of your image sizes: ``` <img...
239,755
<p>In the <em>Settings</em> menu, I have the following menu items listed:</p> <pre><code>Settings -- General -- Writing -- Reading -- Discussion -- Media -- Permalinks -- Blogging </code></pre> <p>I'd like to the <em>Blogging</em> (<code>options-general.php?page=blogging</code>) reordered underneath <em>General</em> ...
[ { "answer_id": 239762, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 2, "selected": false, "text": "<p>The result you get is not surprising, given that you're directly manipulating a global variable. You're replacin...
2016/09/19
[ "https://wordpress.stackexchange.com/questions/239755", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98212/" ]
In the *Settings* menu, I have the following menu items listed: ``` Settings -- General -- Writing -- Reading -- Discussion -- Media -- Permalinks -- Blogging ``` I'd like to the *Blogging* (`options-general.php?page=blogging`) reordered underneath *General* instead of being at the bottom. This was added with the `a...
Got it, thanks to [cjbj](https://wordpress.stackexchange.com/users/75495/cjbj)'s help, I was able to get the final solution: ``` add_filter( 'custom_menu_order', 'submenu_order' ); function submenu_order( $menu_order ) { # Get submenu key location based on slug global $submenu; $settings = $submenu['option...
239,768
<p>Featured image is not displaying on wp-admin side. I have also selected 'featured image' option from <strong>Screen Options</strong>. While Selecting image from media it doesn't show selected image in the metabox. I have written the below code:</p> <pre><code>function twentytwelve_setup() { add_theme_support('pos...
[ { "answer_id": 240355, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": 0, "selected": false, "text": "<p>You can disable/comment these plugin/code one by one by which having <a href=\"https://codex....
2016/09/19
[ "https://wordpress.stackexchange.com/questions/239768", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103109/" ]
Featured image is not displaying on wp-admin side. I have also selected 'featured image' option from **Screen Options**. While Selecting image from media it doesn't show selected image in the metabox. I have written the below code: ``` function twentytwelve_setup() { add_theme_support('post-thumbnails'); } add_act...
Have you double checked if the featured-image section is enabled under the `Screen Options` tab? [![enter image description here](https://i.stack.imgur.com/hQvWY.png)](https://i.stack.imgur.com/hQvWY.png)
239,769
<p>I currently have this snippet: </p> <pre><code>$user = new WP_User(get_current_user_id()); echo $user-&gt;roles[1]; </code></pre> <p>and the output the slug of the bbPress forum role. (roles[0] would be the general WP role but I don't need that.) </p> <p>What I need is the role <strong>name</strong>, not the sl...
[ { "answer_id": 239773, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 3, "selected": false, "text": "<p>I'm not sure if bbPress follows WordPress conventions, but WP has a global class called <a href=\"https://develo...
2016/09/19
[ "https://wordpress.stackexchange.com/questions/239769", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103112/" ]
I currently have this snippet: ``` $user = new WP_User(get_current_user_id()); echo $user->roles[1]; ``` and the output the slug of the bbPress forum role. (roles[0] would be the general WP role but I don't need that.) What I need is the role **name**, not the slug. So, the expected output should be something ...
I'm not sure if bbPress follows WordPress conventions, but WP has a global class called [`$WP-roles`](https://developer.wordpress.org/reference/classes/wp_roles/) that holds the role information. So, starting from what you have, there is the role of the current user: ``` $current_role = $user->roles[1]; ``` Next, re...
239,777
<p>I'm writing a plugin that every time you:</p> <ul> <li>publish a post</li> <li>edit an already published one</li> <li>delete a published post</li> </ul> <p>it makes several queries to the database, gets certain post data (title, excerpt, category, id, url, etc) and exports the in JSON file. This one I'm using it o...
[ { "answer_id": 239776, "author": "bravokeyl", "author_id": 43098, "author_profile": "https://wordpress.stackexchange.com/users/43098", "pm_score": 4, "selected": true, "text": "<p>Extending the above comment:</p>\n\n<p>Directly changing the files of the plugin or theme is not a good prac...
2016/09/19
[ "https://wordpress.stackexchange.com/questions/239777", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/90258/" ]
I'm writing a plugin that every time you: * publish a post * edit an already published one * delete a published post it makes several queries to the database, gets certain post data (title, excerpt, category, id, url, etc) and exports the in JSON file. This one I'm using it on the front end to draw all the elements. ...
Extending the above comment: Directly changing the files of the plugin or theme is not a good practice as once the plugin/theme is updated, you will loose the changes. Instead use child theme in case of themes and hook to required actions in case of plugins. In your case since you are only changing the script in plug...
239,819
<p>Hey I am trying to come up with some logic for if a tag contains any posts</p> <p>I found the below code for a category </p> <pre><code>&lt;?php if (get_category('17')-&gt;category_count &gt; 0) { ?&gt; &lt;?php } ?&gt; </code></pre> <p>I have tried modifying it with <code>get_tag</code> in place of <code>get_ca...
[ { "answer_id": 239823, "author": "bravokeyl", "author_id": 43098, "author_profile": "https://wordpress.stackexchange.com/users/43098", "pm_score": 2, "selected": true, "text": "<p>You can use:</p>\n\n<pre><code>&lt;?php if (get_tag('17')-&gt;count &gt; 0) { ?&gt;\n\n&lt;?php } ?&gt;\n</c...
2016/09/19
[ "https://wordpress.stackexchange.com/questions/239819", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51830/" ]
Hey I am trying to come up with some logic for if a tag contains any posts I found the below code for a category ``` <?php if (get_category('17')->category_count > 0) { ?> <?php } ?> ``` I have tried modifying it with `get_tag` in place of `get_category` which did not work. I thought this could be because `catego...
You can use: ``` <?php if (get_tag('17')->count > 0) { ?> <?php } ?> ``` [`get_tag`](https://developer.wordpress.org/reference/functions/get_tag/) is basically a [`get_term`](https://developer.wordpress.org/reference/functions/get_term/) with taxonomy `post_tag` and `get_term` returns [`WP_Term`](https://developer....
239,846
<p>I have this code, but it shows the total number of posts published by post type 'code'.</p> <pre><code>&lt;?php $count_posts = wp_count_posts('code')-&gt;publish; echo $count_posts; ?&gt; </code></pre> <p>I have 2 post types: 'code' and 'shop'.<br> Post type code is "a child" for post type 'shop'.<br> Therefore I ...
[ { "answer_id": 239848, "author": "RyanCameron.Me", "author_id": 100537, "author_profile": "https://wordpress.stackexchange.com/users/100537", "pm_score": 0, "selected": false, "text": "<pre><code>$count = 0; \n$loop = new WP_Query( array('post_type' =&gt; 'code') );\n\nwhile ( $loop-&gt;...
2016/09/19
[ "https://wordpress.stackexchange.com/questions/239846", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103161/" ]
I have this code, but it shows the total number of posts published by post type 'code'. ``` <?php $count_posts = wp_count_posts('code')->publish; echo $count_posts; ?> ``` I have 2 post types: 'code' and 'shop'. Post type code is "a child" for post type 'shop'. Therefore I need to show the post count for the "...
If you prefer the $wpdb direct queries you can use something like this: ``` global $wpdb; $count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_type = 'code' and post_status = 'publish'" ); echo $count; ``` In the sql query above change the `post_type` to whatever you like. This will return co...
239,853
<p>Sorry for silly question, I'm newbie in Wordpress and PHP. I created a custom post type using <a href="https://code.tutsplus.com/tutorials/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes--wp-27645" rel="nofollow">this</a> tutorial. The category page is working normally, but the single is displ...
[ { "answer_id": 239848, "author": "RyanCameron.Me", "author_id": 100537, "author_profile": "https://wordpress.stackexchange.com/users/100537", "pm_score": 0, "selected": false, "text": "<pre><code>$count = 0; \n$loop = new WP_Query( array('post_type' =&gt; 'code') );\n\nwhile ( $loop-&gt;...
2016/09/19
[ "https://wordpress.stackexchange.com/questions/239853", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81307/" ]
Sorry for silly question, I'm newbie in Wordpress and PHP. I created a custom post type using [this](https://code.tutsplus.com/tutorials/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes--wp-27645) tutorial. The category page is working normally, but the single is displaying all posts from category...
If you prefer the $wpdb direct queries you can use something like this: ``` global $wpdb; $count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_type = 'code' and post_status = 'publish'" ); echo $count; ``` In the sql query above change the `post_type` to whatever you like. This will return co...
239,876
<p>I'm trying to serve different headers based on what type of page the user is on. This is my code.</p> <pre><code>&lt;!-- IF HOME --&gt; &lt;?php if ( is_front_page() &amp;&amp; is_home() ) : ?&gt; &lt;?php get_template_part( 'template-parts/headers/home-header' ); ?&gt; &lt;!-- IF TEMPLATE...
[ { "answer_id": 239878, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": true, "text": "<p>It looks like you're checking if you're on the <code>mobile_photo</code> post type archive with this line:</...
2016/09/20
[ "https://wordpress.stackexchange.com/questions/239876", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103174/" ]
I'm trying to serve different headers based on what type of page the user is on. This is my code. ``` <!-- IF HOME --> <?php if ( is_front_page() && is_home() ) : ?> <?php get_template_part( 'template-parts/headers/home-header' ); ?> <!-- IF TEMPLATES --> <?php elseif ( is_page_templ...
It looks like you're checking if you're on the `mobile_photo` post type archive with this line: ``` <?php elseif ( is_page_template( 'archive-mobile_photo.php' ) ) : ?> ``` If that's indeed the case, use [`is_post_type_archive( $post_types )`](https://codex.wordpress.org/Function_Reference/is_post_type_archive) inst...
239,883
<p>I would like to tick a box while drafting a post which will determine whether:</p> <p>a) only the excerpt for the post is shown on the homepage, linking you to the full post by clicking 'read more' </p> <p>or </p> <p>b) the full post is shown on the homepage with no 'read more' button available... </p> <p>Could ...
[ { "answer_id": 239878, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": true, "text": "<p>It looks like you're checking if you're on the <code>mobile_photo</code> post type archive with this line:</...
2016/09/20
[ "https://wordpress.stackexchange.com/questions/239883", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103175/" ]
I would like to tick a box while drafting a post which will determine whether: a) only the excerpt for the post is shown on the homepage, linking you to the full post by clicking 'read more' or b) the full post is shown on the homepage with no 'read more' button available... Could you please explain how to do th...
It looks like you're checking if you're on the `mobile_photo` post type archive with this line: ``` <?php elseif ( is_page_template( 'archive-mobile_photo.php' ) ) : ?> ``` If that's indeed the case, use [`is_post_type_archive( $post_types )`](https://codex.wordpress.org/Function_Reference/is_post_type_archive) inst...
239,901
<p>I have a technology blog based on wordpress. I would like it to show a icon on top of the menu bar to show new post counter for today. Just like Android Authority website (check here <a href="http://prnt.sc/ck4q62" rel="nofollow">http://prnt.sc/ck4q62</a>) Am a newbie here and i dont know a lot about CSS and Functio...
[ { "answer_id": 239878, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": true, "text": "<p>It looks like you're checking if you're on the <code>mobile_photo</code> post type archive with this line:</...
2016/09/20
[ "https://wordpress.stackexchange.com/questions/239901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103189/" ]
I have a technology blog based on wordpress. I would like it to show a icon on top of the menu bar to show new post counter for today. Just like Android Authority website (check here <http://prnt.sc/ck4q62>) Am a newbie here and i dont know a lot about CSS and Function.php the only thing i know is basic wordpress editi...
It looks like you're checking if you're on the `mobile_photo` post type archive with this line: ``` <?php elseif ( is_page_template( 'archive-mobile_photo.php' ) ) : ?> ``` If that's indeed the case, use [`is_post_type_archive( $post_types )`](https://codex.wordpress.org/Function_Reference/is_post_type_archive) inst...
239,911
<p>I have a hero section on the homepage of my blog that I'd like to be the <strong>main post</strong> and thereafter more posts with a different styles underneath, see below layout: <a href="https://i.stack.imgur.com/Qson1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qson1.png" alt="layout"></a>....
[ { "answer_id": 239878, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": true, "text": "<p>It looks like you're checking if you're on the <code>mobile_photo</code> post type archive with this line:</...
2016/09/20
[ "https://wordpress.stackexchange.com/questions/239911", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103159/" ]
I have a hero section on the homepage of my blog that I'd like to be the **main post** and thereafter more posts with a different styles underneath, see below layout: [![layout](https://i.stack.imgur.com/Qson1.png)](https://i.stack.imgur.com/Qson1.png). I'm not sure how to really approach this and need some guidance ...
It looks like you're checking if you're on the `mobile_photo` post type archive with this line: ``` <?php elseif ( is_page_template( 'archive-mobile_photo.php' ) ) : ?> ``` If that's indeed the case, use [`is_post_type_archive( $post_types )`](https://codex.wordpress.org/Function_Reference/is_post_type_archive) inst...
239,932
<p>I know that I can map multiple domains to individual blogs through plugins. But is it possible to configure WordPress multisite to have more than one parent domain? </p> <p>Ie., a user wants to create a blog. We use the standard form for that, but apart from choosing their own subdomain, I'd like to be able to giv...
[ { "answer_id": 239878, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": true, "text": "<p>It looks like you're checking if you're on the <code>mobile_photo</code> post type archive with this line:</...
2016/09/20
[ "https://wordpress.stackexchange.com/questions/239932", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3986/" ]
I know that I can map multiple domains to individual blogs through plugins. But is it possible to configure WordPress multisite to have more than one parent domain? Ie., a user wants to create a blog. We use the standard form for that, but apart from choosing their own subdomain, I'd like to be able to give them a c...
It looks like you're checking if you're on the `mobile_photo` post type archive with this line: ``` <?php elseif ( is_page_template( 'archive-mobile_photo.php' ) ) : ?> ``` If that's indeed the case, use [`is_post_type_archive( $post_types )`](https://codex.wordpress.org/Function_Reference/is_post_type_archive) inst...
239,942
<p>I have a page template, which is fully working throughout the website other than the pages where the plugin has generated a page such as a job description page, as the plugin that I am using is WP Job Manager. I have tried to include the php file in the functions of the theme and also the template of the theme howev...
[ { "answer_id": 239878, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": true, "text": "<p>It looks like you're checking if you're on the <code>mobile_photo</code> post type archive with this line:</...
2016/09/20
[ "https://wordpress.stackexchange.com/questions/239942", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103223/" ]
I have a page template, which is fully working throughout the website other than the pages where the plugin has generated a page such as a job description page, as the plugin that I am using is WP Job Manager. I have tried to include the php file in the functions of the theme and also the template of the theme however,...
It looks like you're checking if you're on the `mobile_photo` post type archive with this line: ``` <?php elseif ( is_page_template( 'archive-mobile_photo.php' ) ) : ?> ``` If that's indeed the case, use [`is_post_type_archive( $post_types )`](https://codex.wordpress.org/Function_Reference/is_post_type_archive) inst...
239,943
<p>I'm trying to hide posts from a specific category from being featured. Currently, the section shows featured posts from all categories. I need to exclude posts from a category (with category name not by id). </p> <pre><code>$args = array( 'posts_per_page' =&gt; 1, 'meta_key' =&gt; 'meta-checkbox', ...
[ { "answer_id": 239944, "author": "vanurag", "author_id": 70096, "author_profile": "https://wordpress.stackexchange.com/users/70096", "pm_score": -1, "selected": false, "text": "<p>you can add <code>'exclude' =&gt; '',</code> in your args array</p>\n\n<p>or just provide the categ...
2016/09/20
[ "https://wordpress.stackexchange.com/questions/239943", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86147/" ]
I'm trying to hide posts from a specific category from being featured. Currently, the section shows featured posts from all categories. I need to exclude posts from a category (with category name not by id). ``` $args = array( 'posts_per_page' => 1, 'meta_key' => 'meta-checkbox', 'meta_value' =>...
**Excluding specific categories from WP\_Query** This is in the codex. You can exlclude specific categories from WP\_Query. Where array(2, 6) are IDs for categories to be excluded in this example. ``` $query = new WP_Query( array( 'category__not_in' => array( 2, 6 ) ) ); ``` See the codex: <https://codex.wordpress....
239,945
<p>I tried </p> <pre><code>add_filter( 'page_template', 'single_page_template' ); function single_page_template( $template ) { if ( is_singular( 'dwqa-question' ) ) { $template = get_stylesheet_directory() . '/' . page-question.php; } return $template; } </code></pre> <p>now, if I w...
[ { "answer_id": 239951, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 1, "selected": false, "text": "<p>According to the Theme Handbook (<a href=\"https://developer.wordpress.org/themes/template-files-section/...
2016/09/20
[ "https://wordpress.stackexchange.com/questions/239945", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81273/" ]
I tried ``` add_filter( 'page_template', 'single_page_template' ); function single_page_template( $template ) { if ( is_singular( 'dwqa-question' ) ) { $template = get_stylesheet_directory() . '/' . page-question.php; } return $template; } ``` now, if I will out put `echo get_page...
From your question, it seems you're trying to override the single template of a custom post type. If so, the filter you want to use is `single_template` and not `page_template`: ``` function single_page_template($single_template) { global $post; if ($post->post_type == 'dwqa-question') { $single_templ...
240,042
<p>I want to add additional items to the data returned as <a href="https://codex.wordpress.org/Class_Reference/WP_Post" rel="noreferrer"><code>WP_Post</code></a>. So for every function/query that returns a WP_Post object I want my additional data added.</p> <p>Example of returned result:</p> <pre><code>WP_Post (objec...
[ { "answer_id": 240050, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>TLDR; You can't and you shouldn't.</p>\n\n<p>It is <a href=\"https://core.trac.wordpress.org/browser/tags/4.5.3/...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240042", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37896/" ]
I want to add additional items to the data returned as [`WP_Post`](https://codex.wordpress.org/Class_Reference/WP_Post). So for every function/query that returns a WP\_Post object I want my additional data added. Example of returned result: ``` WP_Post (object) => [ // Default data returned by WP_Post ID ...
If your extra data directly references a post meta you don't have to do anything, because `WP_Post` implements the »magic« methods [`__isset()`](https://github.com/WordPress/WordPress/blob/0b81d79c868a3ed3eedbee53805f1cdad5d90351/wp-includes/class-wp-post.php#L252) and [`__get()`](https://github.com/WordPress/WordPress...
240,043
<p>I would like to use the titles within a select element in a form I am echoing to the client side. What would be the best way to do this?</p>
[ { "answer_id": 240048, "author": "Ahmed Fouad", "author_id": 102371, "author_profile": "https://wordpress.stackexchange.com/users/102371", "pm_score": 5, "selected": true, "text": "<p><strong>Query all post titles of a specific post type</strong></p>\n\n<pre><code>// Function that return...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240043", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103297/" ]
I would like to use the titles within a select element in a form I am echoing to the client side. What would be the best way to do this?
**Query all post titles of a specific post type** ``` // Function that returns post titles from specific post type as form select element // returns null if found no results. function output_projects_list() { global $wpdb; $custom_post_type = 'page'; // define your custom post type slug here // A sql qu...
240,061
<p>I am creating plugin that redirects users UNLESS they are visiting from a specific IP.</p> <p>Originally I had this code sat in index.php so it would never load on wp-admin, wp-login pages. However since I have moved this code to a plugin it is. </p> <p>Does anyone know how I can stop the plugin from running while...
[ { "answer_id": 240085, "author": "Anwer AR", "author_id": 83820, "author_profile": "https://wordpress.stackexchange.com/users/83820", "pm_score": 3, "selected": true, "text": "<p>You can try with the following example to stop the code running on <code>admin</code> side or on <code>wp-log...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240061", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71177/" ]
I am creating plugin that redirects users UNLESS they are visiting from a specific IP. Originally I had this code sat in index.php so it would never load on wp-admin, wp-login pages. However since I have moved this code to a plugin it is. Does anyone know how I can stop the plugin from running while user is on wp-lo...
You can try with the following example to stop the code running on `admin` side or on `wp-login.php` page. ``` if ( ! is_admin() || 'wp-login.php' != $GLOBALS['pagenow'] ) { // Do stuff here. code inside this statement will // not run on wp-admin & login page. } ```
240,063
<p>Whilst looking through the <a href="https://codex.wordpress.org/Template_Tags/get_posts" rel="nofollow">codex</a> for the <code>get_posts</code> function, I noticed that in the majority of the examples they do not show an if statement after call to <code>get_posts</code></p> <p>Example: </p> <pre><code>&lt;?php $a...
[ { "answer_id": 240083, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": false, "text": "<p>The <code>get_posts()</code> can return an empty array</p>\n\n<p>In that case the foreach loop is like:</p>\n...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240063", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71627/" ]
Whilst looking through the [codex](https://codex.wordpress.org/Template_Tags/get_posts) for the `get_posts` function, I noticed that in the majority of the examples they do not show an if statement after call to `get_posts` Example: ``` <?php $args = array( 'posts_per_page' => 10, 'order'=> 'ASC', 'orderby' => 'titl...
In my opinion we cannot guarantee the post existence in db for a specific query. maybe it returns an empty array. so its best practice to use the conditional statement. plus i think we are dealing with an array so to check the empty array we should use php `empty` function. for example: ``` if ( !empty( $attachments ...
240,075
<p>I have a WordPress marketing site (<code>www.example.com</code>) and a backend app site (<code>app.example.com</code>). What I am trying to do is this: if some body goes to the URL:</p> <pre><code>www.example.com/profile/&lt;&lt;profileId&gt;&gt; </code></pre> <p>I want to create a page that has mostly generic con...
[ { "answer_id": 240079, "author": "Ahmed Fouad", "author_id": 102371, "author_profile": "https://wordpress.stackexchange.com/users/102371", "pm_score": 1, "selected": false, "text": "<p><strong>Step 1:</strong></p>\n\n<p>Create a page with slug 'profile' in your WordPress Dashboard.</p>\n...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240075", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103307/" ]
I have a WordPress marketing site (`www.example.com`) and a backend app site (`app.example.com`). What I am trying to do is this: if some body goes to the URL: ``` www.example.com/profile/<<profileId>> ``` I want to create a page that has mostly generic content and one `iframe` with `src` ``` my.example.com/profile...
**Step 1:** Create a page with slug 'profile' in your WordPress Dashboard. **Step 2** Use this function to register `profileId` var. ``` add_filter('query_vars', 'wp233_query_vars'); function wp233_query_vars( $query_vars ){ $query_vars[] = 'profileId'; return $query_vars; } ``` And add a rewrite rule to ...
240,081
<p>Im wondering if it's possible to add custom post state's to other pages? Like <em>Frontpage</em> and <em>Blog</em></p> <p>I mean the black text: --Voorpagina (<em>Frontpage</em>)<br> <a href="https://i.stack.imgur.com/gjLzi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gjLzi.png" alt="Post Sta...
[ { "answer_id": 240088, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 2, "selected": false, "text": "<p>Your function doesn't return a value, so you are effectively wiping the existing states.</p>\n<p>...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240081", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103313/" ]
Im wondering if it's possible to add custom post state's to other pages? Like *Frontpage* and *Blog* I mean the black text: --Voorpagina (*Frontpage*) [![Post State WordPresss](https://i.stack.imgur.com/gjLzi.png)](https://i.stack.imgur.com/gjLzi.png) I have tried this in functions.php. ``` add_filter('display_p...
Your function doesn't return a value, so you are effectively wiping the existing states. Also, this hook passes you the current post as an object, so you can use that instead of the global $post. Additionally `get_page_templ‌​ate_slug` returns a path that is relative to your theme's root, so if your theme directory i...
240,089
<p>On my post page I am trying to display list of other posts from the same category of the original post. So far I got this and this does not seem to work:</p> <pre><code>&lt;?php $args = array( 'post_type' =&gt; 'article', 'posts_per_page' =&gt; 5, 'post__not_in' =&gt; array( get_the_ID(...
[ { "answer_id": 240110, "author": "Anwer AR", "author_id": 83820, "author_profile": "https://wordpress.stackexchange.com/users/83820", "pm_score": 1, "selected": false, "text": "<p>you are trying to query the custom post type called <code>article</code>. are you using default WordPress po...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240089", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103317/" ]
On my post page I am trying to display list of other posts from the same category of the original post. So far I got this and this does not seem to work: ``` <?php $args = array( 'post_type' => 'article', 'posts_per_page' => 5, 'post__not_in' => array( get_the_ID() ), 'category' ...
I've found an answer: ``` <?php $cats = get_the_category(); $args = array( 'post_type' => 'article', 'post__not_in' => array( get_the_ID() ), 'posts_per_page' => 5, 'cat' => $cats[0]->term_id, 'meta_query' => array( array( 'ke...
240,092
<p>I want to change my image size. Large is now 600px wide but I want it to be 800px wide.</p> <p>In many pages I have embedded images like this:</p> <pre><code>&lt;img class="alignnone size-large wp-image-261" src="http://xxxxxxxxxx-600x456.jpg" width="600" height="456" /&gt; </code></pre> <p>I changed ...
[ { "answer_id": 240110, "author": "Anwer AR", "author_id": 83820, "author_profile": "https://wordpress.stackexchange.com/users/83820", "pm_score": 1, "selected": false, "text": "<p>you are trying to query the custom post type called <code>article</code>. are you using default WordPress po...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240092", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103320/" ]
I want to change my image size. Large is now 600px wide but I want it to be 800px wide. In many pages I have embedded images like this: ``` <img class="alignnone size-large wp-image-261" src="http://xxxxxxxxxx-600x456.jpg" width="600" height="456" /> ``` I changed the size of large images in the media s...
I've found an answer: ``` <?php $cats = get_the_category(); $args = array( 'post_type' => 'article', 'post__not_in' => array( get_the_ID() ), 'posts_per_page' => 5, 'cat' => $cats[0]->term_id, 'meta_query' => array( array( 'ke...
240,100
<p>i have a theme where first a featured post is displayed. then there is a grid of posts. Problem is grid also displays the featured post. So, featured post appears twice.</p> <p>Question is <strong>how to hide featured post from grid?</strong></p> <p>Note that a custom meta box has been added to mark post/page as f...
[ { "answer_id": 240101, "author": "mlimon", "author_id": 64458, "author_profile": "https://wordpress.stackexchange.com/users/64458", "pm_score": -1, "selected": false, "text": "<p><code>caller_get_posts</code> is deprecated since version 3.1!</p>\n\n<p>Use <code>ignore_sticky_posts</code>...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240100", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86147/" ]
i have a theme where first a featured post is displayed. then there is a grid of posts. Problem is grid also displays the featured post. So, featured post appears twice. Question is **how to hide featured post from grid?** Note that a custom meta box has been added to mark post/page as featured. loop that starts fea...
wp section of stackexchange really seems half dead. you rarely get issue sorted. have\_posts checks whether there is any post, so add another condition that checks whether the post is featured or not. ``` if(have_posts()) : while(have_posts()) : the_post(); ``` replace above with below ``` if(have_posts() && th...
240,134
<p>I've made <strong>my own PHP page</strong> and used it as a part of my WordPress website. I'm using some WordPress functions and want to have it fully integrated with WordPress itself.</p> <p>Although I've loaded WordPress, the Admin Bar is not loading at the top of the page. <strong>It actually doesn't even show ...
[ { "answer_id": 240152, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 4, "selected": true, "text": "<p>If WordPress is loaded from outside of the main WordPress files using a separate PHP script that includes <c...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240134", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101670/" ]
I've made **my own PHP page** and used it as a part of my WordPress website. I'm using some WordPress functions and want to have it fully integrated with WordPress itself. Although I've loaded WordPress, the Admin Bar is not loading at the top of the page. **It actually doesn't even show in HTML structure** (I tried t...
If WordPress is loaded from outside of the main WordPress files using a separate PHP script that includes `wp-load.php` then the `/template-loader.php` file will not be loaded and therefore the `template_redirect` action will not be triggered. This is important because `template_redirect` is how the Toolbar is initial...
240,137
<p>Edit:</p> <p>In a plugin I am developing, I need to store payments, IPN and transactions for customers in both frontend and backend. However I am concerned that the admin will use his actions power to delete the transactions or financial data from site which has bad implications.</p> <h3>Question</h3> <p>How can ...
[ { "answer_id": 240180, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 3, "selected": false, "text": "<p>A better way to prevent deletion would be to disable that <a href=\"https://codex.wordpress.org/Roles_and_Capabi...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240137", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102371/" ]
Edit: In a plugin I am developing, I need to store payments, IPN and transactions for customers in both frontend and backend. However I am concerned that the admin will use his actions power to delete the transactions or financial data from site which has bad implications. ### Question How can I prevent the admin fr...
Here's another approach using the `map_meta_cap` filter that's applied within the [`map_meta_cap()`](https://developer.wordpress.org/reference/functions/map_meta_cap/) function within the `has_cap()` method of the `WP_User` class (*PHP 5.4+*): ``` add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id, $args ) {...
240,138
<p>i m creating a AJAX live search to filter posts title in my wordpress theme. As i write something in input it show all the post in result, Not filtering it to get custom post..</p> <p><strong>How to search live and find a post with AJAX??</strong></p> <p><strong>Function.php</strong></p> <pre><code>&lt;?php add...
[ { "answer_id": 240143, "author": "Ahmed Fouad", "author_id": 102371, "author_profile": "https://wordpress.stackexchange.com/users/102371", "pm_score": 6, "selected": true, "text": "<p>Here is a working solution (tested as is)</p>\n<p><strong>The HTML (could be part of page content)</stro...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240138", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/97572/" ]
i m creating a AJAX live search to filter posts title in my wordpress theme. As i write something in input it show all the post in result, Not filtering it to get custom post.. **How to search live and find a post with AJAX??** **Function.php** ``` <?php add_action('wp_ajax_my_action' , 'data_fetch'); add_action('...
Here is a working solution (tested as is) **The HTML (could be part of page content)** ``` <input type="text" name="keyword" id="keyword" onkeyup="fetch()"></input> <div id="datafetch">Search results will appear here</div> ``` **The JavaScript ( goes to your theme's functions.php )** ``` // add the ajax fetch js ...
240,149
<p>I have a custom field on a WooCommerce product, and I am entering the ID of another product into it. When saving that product, I am adding a meta field to the product that was inputted, creating a "link" between them. I have this working fine, but the issue is that it adds it even it is already there. </p> <pre><co...
[ { "answer_id": 240150, "author": "Ahmed Fouad", "author_id": 102371, "author_profile": "https://wordpress.stackexchange.com/users/102371", "pm_score": 3, "selected": true, "text": "<p>It looks like you need to use <code>update_post_meta()</code></p>\n\n<p><a href=\"https://codex.wordpres...
2016/09/21
[ "https://wordpress.stackexchange.com/questions/240149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103352/" ]
I have a custom field on a WooCommerce product, and I am entering the ID of another product into it. When saving that product, I am adding a meta field to the product that was inputted, creating a "link" between them. I have this working fine, but the issue is that it adds it even it is already there. ``` function pa...
It looks like you need to use `update_post_meta()` <https://codex.wordpress.org/Function_Reference/update_post_meta> **Source: WP Codex** The function update\_post\_meta() updates the value of an existing meta key (custom field) for the specified post. **This may be used in place of add\_post\_meta() function.** Th...
240,189
<p>I want to seperate my Option-Page functions and functions.php.<br> Therefore i moved Option-Page functions to another file "includes/options.php".<br> Including the file with require_once("includes/options.php") does not work <strong>anymore</strong> (I am absolutely sure that it worked in past), but require_once("i...
[ { "answer_id": 240199, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>Never use relative paths to include PHP files, you just have no real idea relative to what it will end up...
2016/09/22
[ "https://wordpress.stackexchange.com/questions/240189", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103388/" ]
I want to seperate my Option-Page functions and functions.php. Therefore i moved Option-Page functions to another file "includes/options.php". Including the file with require\_once("includes/options.php") does not work **anymore** (I am absolutely sure that it worked in past), but require\_once("includes/options....
If you are editing theme files use `get_template_directory` to retrieve the php files. try the code below in your `functions.php` file. ``` require get_template_directory() . '/includes/option.php'; ```
240,206
<p>I currently have this custom query which I am trying to filter the product (paintings) by artist.</p> <pre><code> $artistID = $_GET['artist_id']; $args = array( 'post_type' =&gt; 'product', 'meta_query' =&gt; array( ...
[ { "answer_id": 240208, "author": "FaCE", "author_id": 96768, "author_profile": "https://wordpress.stackexchange.com/users/96768", "pm_score": 2, "selected": false, "text": "<p>You're almost there -- you just need to add the comparison to your meta query:</p>\n\n<pre><code>$args = array(\...
2016/09/22
[ "https://wordpress.stackexchange.com/questions/240206", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59547/" ]
I currently have this custom query which I am trying to filter the product (paintings) by artist. ``` $artistID = $_GET['artist_id']; $args = array( 'post_type' => 'product', 'meta_query' => array( array( ...
You're almost there -- you just need to add the comparison to your meta query: ``` $args = array( 'post_type' => 'product', 'meta_query' => array( array( 'key' => 'artist', 'value' => $artistID, 'compare' => '=' ) ) ); ``` <https://codex.wordpress.org/Class_Reference/WP_Met...
240,219
<p>I am using the WP_bootstrap_navwalker for a dropdown menu. This works fine, but it only shows me the first and second level items. So de dropdown on the first level and a regular second item when dropdown is open. The third level is not visible. </p> <p>I want to display it under my second level items. The walker ...
[ { "answer_id": 263781, "author": "Md.Tauhidul Islam", "author_id": 117774, "author_profile": "https://wordpress.stackexchange.com/users/117774", "pm_score": 2, "selected": false, "text": "<p>I solved this problem. follow these instructions.....</p>\n\n<ol>\n<li><p>Add script</p>\n\n<pre>...
2016/09/22
[ "https://wordpress.stackexchange.com/questions/240219", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103408/" ]
I am using the WP\_bootstrap\_navwalker for a dropdown menu. This works fine, but it only shows me the first and second level items. So de dropdown on the first level and a regular second item when dropdown is open. The third level is not visible. I want to display it under my second level items. The walker is now ma...
I solved this problem. follow these instructions..... 1. Add script ``` (function($){ $(document).ready(function(){ $('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) { event.preventDefault(); event.stopPropagation(); $(this).parent().siblings().removeClass('open');...
240,221
<p>Currently my page titles are handled by WordPress, in a call to wp_head (I have add_theme_support( 'title-tag' ) in functions.php). I'd like to change the page title format for category archives - currently these look like</p> <pre><code>&lt;Category name&gt; Archives - &lt;Site name&gt; </code></pre> <p>I'd like ...
[ { "answer_id": 240223, "author": "Fencer04", "author_id": 98527, "author_profile": "https://wordpress.stackexchange.com/users/98527", "pm_score": 0, "selected": false, "text": "<p>If you only want to edit the title tag () and not what is at the top of the page you can do this:</p>\n\n<pr...
2016/09/22
[ "https://wordpress.stackexchange.com/questions/240221", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29118/" ]
Currently my page titles are handled by WordPress, in a call to wp\_head (I have add\_theme\_support( 'title-tag' ) in functions.php). I'd like to change the page title format for category archives - currently these look like ``` <Category name> Archives - <Site name> ``` I'd like them just to be: ``` <Category nam...
If you're using the Yoast SEO plugin (which it looks like you are) then [this](https://wordpress.stackexchange.com/a/163023/96768) answer might help you > > If you are using yoast SEO plugin then the easiest method is to remove > the archive word from "titles & metas-> Taxonomies->category" > > > find: > > > %%t...
240,254
<p>I want to check if a post already exists. This includes to check if the post exists as draft as well. But I struggle a little bit with the wordpress API v2. <a href="http://v2.wp-api.org/reference/posts/" rel="noreferrer">http://v2.wp-api.org/reference/posts/</a><br> Under <strong>List Posts</strong> -> status they...
[ { "answer_id": 246781, "author": "Jack Lenox", "author_id": 7437, "author_profile": "https://wordpress.stackexchange.com/users/7437", "pm_score": 3, "selected": true, "text": "<p>I think the query parameter that you want for post status is:</p>\n\n<pre><code>status=draft\n</code></pre>\n...
2016/09/22
[ "https://wordpress.stackexchange.com/questions/240254", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102247/" ]
I want to check if a post already exists. This includes to check if the post exists as draft as well. But I struggle a little bit with the wordpress API v2. <http://v2.wp-api.org/reference/posts/> Under **List Posts** -> status they say > > Limit result set to posts assigned a specific status. > > Default: pub...
I think the query parameter that you want for post status is: ``` status=draft ``` Let me know if this doesn't work.
240,263
<p>I am using <code>wp_dropdown_pages</code> in the backend of my site to generate a list of pages according to a specific set of criteria.</p> <p>The list only shows <strong><em>published posts</em></strong> where I would like it to show both published posts <strong><em>and drafts</em></strong>.</p> <p>I have found ...
[ { "answer_id": 246781, "author": "Jack Lenox", "author_id": 7437, "author_profile": "https://wordpress.stackexchange.com/users/7437", "pm_score": 3, "selected": true, "text": "<p>I think the query parameter that you want for post status is:</p>\n\n<pre><code>status=draft\n</code></pre>\n...
2016/09/22
[ "https://wordpress.stackexchange.com/questions/240263", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103436/" ]
I am using `wp_dropdown_pages` in the backend of my site to generate a list of pages according to a specific set of criteria. The list only shows ***published posts*** where I would like it to show both published posts ***and drafts***. I have found other Stack Exchange threads which show how to accomplish this in th...
I think the query parameter that you want for post status is: ``` status=draft ``` Let me know if this doesn't work.
240,272
<p>I'm am setting up my first network site on a subdirectory based network.</p> <p>My <code>.htaccess</code> is copied directly from the "Network Setup" page of the network admin panel. This is currently in the file:</p> <pre><code># BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # add...
[ { "answer_id": 246781, "author": "Jack Lenox", "author_id": 7437, "author_profile": "https://wordpress.stackexchange.com/users/7437", "pm_score": 3, "selected": true, "text": "<p>I think the query parameter that you want for post status is:</p>\n\n<pre><code>status=draft\n</code></pre>\n...
2016/09/22
[ "https://wordpress.stackexchange.com/questions/240272", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64943/" ]
I'm am setting up my first network site on a subdirectory based network. My `.htaccess` is copied directly from the "Network Setup" page of the network admin panel. This is currently in the file: ``` # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # add a trailing slash to /wp-admin R...
I think the query parameter that you want for post status is: ``` status=draft ``` Let me know if this doesn't work.
240,273
<p>I'm making a plugin that compares data from external API with meta items in WordPress backoffice.</p> <p>I tried using <code>wp_remote_get</code> method to query my API but it doesn't return anything, nobody, nothing. When accessed directly with the same URL in browser the API generates JSON array without problems....
[ { "answer_id": 264002, "author": "antonio polastri", "author_id": 117895, "author_profile": "https://wordpress.stackexchange.com/users/117895", "pm_score": 3, "selected": false, "text": "<p>Check with these args</p>\n\n<pre><code>$args = array(\n 'timeout' =&gt; 10,\n 'sslverif...
2016/09/22
[ "https://wordpress.stackexchange.com/questions/240273", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103264/" ]
I'm making a plugin that compares data from external API with meta items in WordPress backoffice. I tried using `wp_remote_get` method to query my API but it doesn't return anything, nobody, nothing. When accessed directly with the same URL in browser the API generates JSON array without problems. What am I doing wro...
Check with these args ``` $args = array( 'timeout' => 10, 'sslverify' => false ); ```
240,295
<p>I want to provide functionality to create a single post into my custom post type. And for this, when user click on main option (name of post) at left side bar in word-press back-end It's automatically redirect on "Add New Post" or if a post already created then automatically redirect on "Edit Post" (existing post ed...
[ { "answer_id": 264002, "author": "antonio polastri", "author_id": 117895, "author_profile": "https://wordpress.stackexchange.com/users/117895", "pm_score": 3, "selected": false, "text": "<p>Check with these args</p>\n\n<pre><code>$args = array(\n 'timeout' =&gt; 10,\n 'sslverif...
2016/09/23
[ "https://wordpress.stackexchange.com/questions/240295", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102479/" ]
I want to provide functionality to create a single post into my custom post type. And for this, when user click on main option (name of post) at left side bar in word-press back-end It's automatically redirect on "Add New Post" or if a post already created then automatically redirect on "Edit Post" (existing post edit)...
Check with these args ``` $args = array( 'timeout' => 10, 'sslverify' => false ); ```
240,330
<p>I'm try to exclude a specific category from a list of categories that a custom post has (in this case 'Uncategorized' - ID: 1).</p> <p>I've tried <code>exclude</code>:</p> <pre><code>wp_list_categories([ 'include' =&gt; wp_list_pluck(get_the_category(), 'term_id'), 'title_li' =&gt; '', 'exclude' =&gt; 1 ]); ...
[ { "answer_id": 240332, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>The <code>wp_list_categories()</code> function uses <code>get_terms()</code> behind the scenes, where the <a ...
2016/09/23
[ "https://wordpress.stackexchange.com/questions/240330", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4109/" ]
I'm try to exclude a specific category from a list of categories that a custom post has (in this case 'Uncategorized' - ID: 1). I've tried `exclude`: ``` wp_list_categories([ 'include' => wp_list_pluck(get_the_category(), 'term_id'), 'title_li' => '', 'exclude' => 1 ]); ``` But it still appears. How can I mak...
The `wp_list_categories()` function uses `get_terms()` behind the scenes, where the [documentation](https://developer.wordpress.org/reference/functions/get_terms/#parameters) for the `exclude` argument says: > > If `$include` is non-empty, `$exclude` is ignored. > > > Instead you could try to exclude the `term_id...
240,352
<p>I often find the need to add class or ID's to Wordpress functions. Preferably I would like to do this in the a template (not in <code>functions.php</code>).</p> <p>Example: <code>&lt;?php the_excerpt(); ?&gt;</code> Will output the excerpt inside <code>&lt;p&gt;</code>. How can I add a class to the paragraph so tha...
[ { "answer_id": 240364, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>the way to do this is by wrapping everything in a div with whatever class you want, like</p>\n\n<pre><cod...
2016/09/23
[ "https://wordpress.stackexchange.com/questions/240352", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82313/" ]
I often find the need to add class or ID's to Wordpress functions. Preferably I would like to do this in the a template (not in `functions.php`). Example: `<?php the_excerpt(); ?>` Will output the excerpt inside `<p>`. How can I add a class to the paragraph so that I get `<p class="something">The excerpt text...</p>`
If you have only one template it's fine to do something like: ``` echo '<p class="whatever">' . get_the_excerpt() . '</p>'; ``` However, if you have multiple templates and want to control the classes centrally, you can make a filter on [`get_the_excerpt`](https://developer.wordpress.org/reference/hooks/get_the_excer...
240,381
<p>I have this form:</p> <pre><code>&lt;form action="&lt;?php the permalink(); ?&gt;" method="get" &gt; &lt;input type="hidden" name="taxo" value="question" /&gt; &lt;select name = "cata"&gt; &lt;option value='unique_name-a'&gt;xxx&lt;/option&gt; &lt;option value='foo'&gt;yyy&lt;/option&gt; &lt;option value='bar...
[ { "answer_id": 240364, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>the way to do this is by wrapping everything in a div with whatever class you want, like</p>\n\n<pre><cod...
2016/09/23
[ "https://wordpress.stackexchange.com/questions/240381", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16969/" ]
I have this form: ``` <form action="<?php the permalink(); ?>" method="get" > <input type="hidden" name="taxo" value="question" /> <select name = "cata"> <option value='unique_name-a'>xxx</option> <option value='foo'>yyy</option> <option value='bar'>zzz</option> </select> <select name ="catb"> <option value='u...
If you have only one template it's fine to do something like: ``` echo '<p class="whatever">' . get_the_excerpt() . '</p>'; ``` However, if you have multiple templates and want to control the classes centrally, you can make a filter on [`get_the_excerpt`](https://developer.wordpress.org/reference/hooks/get_the_excer...
240,422
<p>I am trying to make a query to take first 3 categories with most posts per user, but no luck so far. This is where I am now:</p> <pre> <code> SELECT DISTINCT(terms.term_id) as term_ID, terms.name, terms.slug, posts.post_author, t0.count_id FROM wp_posts as posts JOIN wp_term_relationships as relationships ON posts...
[ { "answer_id": 240364, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>the way to do this is by wrapping everything in a div with whatever class you want, like</p>\n\n<pre><cod...
2016/09/24
[ "https://wordpress.stackexchange.com/questions/240422", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65361/" ]
I am trying to make a query to take first 3 categories with most posts per user, but no luck so far. This is where I am now: ``` SELECT DISTINCT(terms.term_id) as term_ID, terms.name, terms.slug, posts.post_author, t0.count_id FROM wp_posts as posts JOIN wp_term_relationships as relationships ON posts.ID = relations...
If you have only one template it's fine to do something like: ``` echo '<p class="whatever">' . get_the_excerpt() . '</p>'; ``` However, if you have multiple templates and want to control the classes centrally, you can make a filter on [`get_the_excerpt`](https://developer.wordpress.org/reference/hooks/get_the_excer...
240,429
<p>I have remarked that when clicking on a tag I have a list of posts displayed differently that when I use search box.</p> <p>How to force tag page layout to use same as search layout for any template ?</p>
[ { "answer_id": 240443, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>If you take a look at the <a href=\"https://developer.wordpress.org/files/2014/10/template-hierarchy.png\" rel=\...
2016/09/24
[ "https://wordpress.stackexchange.com/questions/240429", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4078/" ]
I have remarked that when clicking on a tag I have a list of posts displayed differently that when I use search box. How to force tag page layout to use same as search layout for any template ?
You can tell WordPress to use the `search.php` template whenever viewing tags by using the [`template_include`](https://codex.wordpress.org/Plugin_API/Filter_Reference/template_include). It works like this: ``` function wpse_240429() { // IF we're planning on loading a tag template if( is_tag() ) { /...
240,446
<p>I'm trying to override WP's default URL structure for attachments where, if they're attached to a post, the URL is /post-slug/attachment-slug/ and if not it's simply /attachment-slug/.</p> <p>What I'd like instead is for attachments to behave like posts in that they have an archive and all URLs point to /archive-sl...
[ { "answer_id": 240443, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>If you take a look at the <a href=\"https://developer.wordpress.org/files/2014/10/template-hierarchy.png\" rel=\...
2016/09/24
[ "https://wordpress.stackexchange.com/questions/240446", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23714/" ]
I'm trying to override WP's default URL structure for attachments where, if they're attached to a post, the URL is /post-slug/attachment-slug/ and if not it's simply /attachment-slug/. What I'd like instead is for attachments to behave like posts in that they have an archive and all URLs point to /archive-slug/attachm...
You can tell WordPress to use the `search.php` template whenever viewing tags by using the [`template_include`](https://codex.wordpress.org/Plugin_API/Filter_Reference/template_include). It works like this: ``` function wpse_240429() { // IF we're planning on loading a tag template if( is_tag() ) { /...
240,496
<p>Relatively new to anything that doesn't require common sense in WordPress. My previous site was built poorly etc, so cutting a long story short I installed a new theme and started building up pages again etc. </p> <p>I have ran various diagnostics on seo etc while I am working and seem to have problems with indexab...
[ { "answer_id": 240499, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>Well, that message is pretty self explanatory. There is no sitemap linked in your <code>robots.txt</code> file. ...
2016/09/25
[ "https://wordpress.stackexchange.com/questions/240496", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103596/" ]
Relatively new to anything that doesn't require common sense in WordPress. My previous site was built poorly etc, so cutting a long story short I installed a new theme and started building up pages again etc. I have ran various diagnostics on seo etc while I am working and seem to have problems with indexability and ...
Well, that message is pretty self explanatory. There is no sitemap linked in your `robots.txt` file. So you check if you have a sitemap (if not install a plugin that will generate one for you) and add this line to your robots.txt file in the root of your site: ``` Sitemap: http://www.example.com/sitemap.xml ```
240,508
<p>I'm running WP CLI and MAMP on my MacBook for a local development environment. My version of WP CLI is current (0.24.1). I've just upgraded MAMP to it's latest version (4.0.4), which also upgrades to MySQL 5.6. After running the upgrade, I began receiving a fatal error when calling any WP CLI command that involves a...
[ { "answer_id": 240509, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>The compatibility problem can be a result of your php version, php settings or/and wordpress version. the...
2016/09/25
[ "https://wordpress.stackexchange.com/questions/240508", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64689/" ]
I'm running WP CLI and MAMP on my MacBook for a local development environment. My version of WP CLI is current (0.24.1). I've just upgraded MAMP to it's latest version (4.0.4), which also upgrades to MySQL 5.6. After running the upgrade, I began receiving a fatal error when calling any WP CLI command that involves a da...
Resolved the issue. The problem was that the default PHP version changed with the new version of MAMP, and I had set the path in .bash\_profile to the explicit version of the previous MAMP install. Once I edited the .bash\_profile to dynamically find the version of PHP in use, everything works perfectly.
240,517
<p>User registrations are working great, except that the password that he chose isn't being accepted when the user tries to sign in, generating a new password from the back-end and trying to login with the generated password works. what am i missing here?</p> <pre><code>$email = $_POST["email"]; $password = $_POST["pa...
[ { "answer_id": 240509, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>The compatibility problem can be a result of your php version, php settings or/and wordpress version. the...
2016/09/25
[ "https://wordpress.stackexchange.com/questions/240517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98968/" ]
User registrations are working great, except that the password that he chose isn't being accepted when the user tries to sign in, generating a new password from the back-end and trying to login with the generated password works. what am i missing here? ``` $email = $_POST["email"]; $password = $_POST["password1"]; $fi...
Resolved the issue. The problem was that the default PHP version changed with the new version of MAMP, and I had set the path in .bash\_profile to the explicit version of the previous MAMP install. Once I edited the .bash\_profile to dynamically find the version of PHP in use, everything works perfectly.
240,529
<p>I had something really working well - a search page with a custom url. It works fine except when I add the 404.php page to my theme. Then the page 404s. And if I remove it, it starts to work again.</p> <p>Is there a way I can check for a 404 for this url and "cancel" it? I've tried that, sort of, by checking <code>...
[ { "answer_id": 241344, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 0, "selected": false, "text": "<p>I think you're looking in the wrong direction for a solution. In stead of trying to prevent a search with zero r...
2016/09/26
[ "https://wordpress.stackexchange.com/questions/240529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/66892/" ]
I had something really working well - a search page with a custom url. It works fine except when I add the 404.php page to my theme. Then the page 404s. And if I remove it, it starts to work again. Is there a way I can check for a 404 for this url and "cancel" it? I've tried that, sort of, by checking `$GLOBALS['wp_qu...
Redirect early ============== First of all, your redirect function should be hooked early: you are not relying on query variables there, so you could use `init` hook: ``` function search_redirect() { if (!empty($_GET['s'])) { $home = trailingslashit(home_url('catalog-of-work')); wp_safe_redirect($ho...
240,576
<p>Good afternoon!</p> <p>This is an issue regarding the Wordpress backend and custom post types. I have spent all Friday searching and trying possible solutions and, while they helped others, in my case they're not doing what I need.</p> <h1>Status quo</h1> <p>I have a custom post type called "anco_project" it uses...
[ { "answer_id": 240567, "author": "danhgilmore", "author_id": 819, "author_profile": "https://wordpress.stackexchange.com/users/819", "pm_score": 4, "selected": true, "text": "<p>Yes, if you assign 'promote_users' to another user, that user could promote non-site admins to site admin.</p>...
2016/09/26
[ "https://wordpress.stackexchange.com/questions/240576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39243/" ]
Good afternoon! This is an issue regarding the Wordpress backend and custom post types. I have spent all Friday searching and trying possible solutions and, while they helped others, in my case they're not doing what I need. Status quo ========== I have a custom post type called "anco\_project" it uses very few WP g...
Yes, if you assign 'promote\_users' to another user, that user could promote non-site admins to site admin. <https://codex.wordpress.org/Roles_and_Capabilities#promote_users>
240,578
<p>when I try to show the thumbnail image with a href tag to refer to the post page it only shows the link next to the picture and the image is not clickable.</p> <pre><code>echo "&lt;head&gt; &lt;style&gt; img { margin-left: 25px; margin-right: 25px; } &lt;/style&gt; ...
[ { "answer_id": 240585, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": false, "text": "<p><code>the_permalink()</code> and <code>the_post_thumbnail()</code> echo their output. Use the <code>\"get_*...
2016/09/26
[ "https://wordpress.stackexchange.com/questions/240578", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103400/" ]
when I try to show the thumbnail image with a href tag to refer to the post page it only shows the link next to the picture and the image is not clickable. ``` echo "<head> <style> img { margin-left: 25px; margin-right: 25px; } </style> </head> <body> ...
Found a solution myself: ``` echo "<head> <style> img { margin-left: 25px; margin-right: 25px; } </style> </head> <body> <a href='".get_the_permalink()."' target='_blank'>"; the_post_thumbnail('video'); echo "</a> ...
240,622
<p>I'm a bit puzzled when I after some time did another Wordpress install.</p> <p>I'm using a standard Apache + PHP 7 combination (even under version control) and after checking out 4.6.1 of Wordpress (the tagged version from the Github SVN mirror, the <a href="https://github.com/WordPress/WordPress" rel="nofollow nor...
[ { "answer_id": 240627, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 4, "selected": true, "text": "<p>WordPress will use <a href=\"http://php.net/manual/en/book.mysqli.php\">MySQLi</a> when <a href=\"https:/...
2016/09/26
[ "https://wordpress.stackexchange.com/questions/240622", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/178/" ]
I'm a bit puzzled when I after some time did another Wordpress install. I'm using a standard Apache + PHP 7 combination (even under version control) and after checking out 4.6.1 of Wordpress (the tagged version from the Github SVN mirror, the [official Git-ified version](https://github.com/WordPress/WordPress)) the in...
WordPress will use [MySQLi](http://php.net/manual/en/book.mysqli.php) when [it can](https://github.com/WordPress/WordPress/blob/4a6f90db58a935abb688cfb91b391dffeda7b35c/wp-includes/wp-db.php#L638-L646) or unless you tell it not to. Unfortunately if WP doesn't see a `mysqli_*` function, it will assume that you want to u...
240,644
<p>I have attempted the following a few different ways. The current way I have the functionality works fine but does NOT utilize the WP Media Uploader (which makes finding 1600+ PDF files on the site to upload cumbersome). I recently found the below snippet of code and tweaked it to work for WooCommerce products.</p> ...
[ { "answer_id": 252850, "author": "Laurence Tuck", "author_id": 1426, "author_profile": "https://wordpress.stackexchange.com/users/1426", "pm_score": 1, "selected": false, "text": "<p>The simplest way to do this is with a plugin. I use ACF (<a href=\"https://wordpress.org/plugins/advanced...
2016/09/27
[ "https://wordpress.stackexchange.com/questions/240644", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103425/" ]
I have attempted the following a few different ways. The current way I have the functionality works fine but does NOT utilize the WP Media Uploader (which makes finding 1600+ PDF files on the site to upload cumbersome). I recently found the below snippet of code and tweaked it to work for WooCommerce products. The onl...
Hey all (especially @Innate), I was able to sort it out ages ago but clearly forgot to come back here and share how I did it. I ended up nixing the idea of using the Media Uploader (due to it being hit-or-miss with larger PDF uploads) and instead just used the text field. I gave the client FTP access under a specific s...
240,647
<p>I tried to upload fonts in WordPress in <code>wp-includes/fonts</code>. Then I go in <code>Apperance -&gt; Editor -&gt; Style.css</code> and here I have something like this</p> <pre><code>@font-face { font-family: helvetica_light; src: url(/wp-includes/fonts/helvetica_light.otf); } </code></pre> <p><a href...
[ { "answer_id": 240652, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 1, "selected": false, "text": "<p>You should <em>never</em> touch any files in <code>wp-includes</code> or <code>wp-admin</code>. Why? Because th...
2016/09/27
[ "https://wordpress.stackexchange.com/questions/240647", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103629/" ]
I tried to upload fonts in WordPress in `wp-includes/fonts`. Then I go in `Apperance -> Editor -> Style.css` and here I have something like this ``` @font-face { font-family: helvetica_light; src: url(/wp-includes/fonts/helvetica_light.otf); } ``` [![Looking in console I saw this error..I want to know why an...
You should *never* touch any files in `wp-includes` or `wp-admin`. Why? Because the next time you update WordPress, any changes you made will get erased. **Option 1 - Easy** If you want to use Google fonts with your WordPress theme, try a plugin like [Easy Google Fonts](https://wordpress.org/plugins/easy-google-font...
240,653
<p>I'm trying to query a single product. And I searched it to google on how to do it and a found this code.</p> <pre><code>do_shortcode('[product_page id="{$product_id}"]'); </code></pre> <p>but this dispaly the whole content of products. All I want is just an image,description and the price. How can I do this using ...
[ { "answer_id": 240700, "author": "Anass", "author_id": 77227, "author_profile": "https://wordpress.stackexchange.com/users/77227", "pm_score": -1, "selected": false, "text": "<p>Why not just use the shortcode that provides <em>WooCommerce</em> by default?\nI think is more practical than ...
2016/09/27
[ "https://wordpress.stackexchange.com/questions/240653", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103627/" ]
I'm trying to query a single product. And I searched it to google on how to do it and a found this code. ``` do_shortcode('[product_page id="{$product_id}"]'); ``` but this dispaly the whole content of products. All I want is just an image,description and the price. How can I do this using WP\_QUERY()?
If you want to use the `Wp_Query` for selecting the single product from the database you have to pass the `p` in the `$args` so that if fetches the data and the `post_type` should be as `product`. > > Follow up the Normal `$args` method along with that you have to add the following lines of code. > > > ``` <?php ...
240,658
<p>jQuery included with WordPress is in <a href="http://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/" rel="nofollow">compatibility mode</a>. To avoid conflicts with other libraries we can not use the '$' shortcut for 'jQuery'.</p> <p>To use the '$' sign we use:</p> <pre><code>jQuery(document).r...
[ { "answer_id": 240659, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 4, "selected": true, "text": "<p>Using a self invoking anonymous function that passes the jQuery object will do the trick:</p>\n\n<pre><code>...
2016/09/27
[ "https://wordpress.stackexchange.com/questions/240658", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81898/" ]
jQuery included with WordPress is in [compatibility mode](http://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/). To avoid conflicts with other libraries we can not use the '$' shortcut for 'jQuery'. To use the '$' sign we use: ``` jQuery(document).ready(function($) { $('#myid').css({'backgrou...
Using a self invoking anonymous function that passes the jQuery object will do the trick: ``` (function($){ $(window).load(function(){ $('#myid').css({'background': 'black', 'color':'white'}); }); })(jQuery); //Passing the jQuery object as a first argument ```
240,670
<p>I have a subdomain:</p> <pre><code>https://blog.example.com/ </code></pre> <p>I forcibly redirects to directory:</p> <pre><code>https://www.example.com/blog </code></pre> <p>By changing site URL and some RewriteRule on .htaccess.</p> <p>My <strong>.htaccess</strong>:</p> <pre><code> &lt;IfModule mod_rewrite...
[ { "answer_id": 271712, "author": "Diego", "author_id": 122801, "author_profile": "https://wordpress.stackexchange.com/users/122801", "pm_score": 2, "selected": false, "text": "<p>wp-admin-canonical is <a href=\"https://core.trac.wordpress.org/ticket/35561\" rel=\"nofollow noreferrer\">br...
2016/09/27
[ "https://wordpress.stackexchange.com/questions/240670", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63027/" ]
I have a subdomain: ``` https://blog.example.com/ ``` I forcibly redirects to directory: ``` https://www.example.com/blog ``` By changing site URL and some RewriteRule on .htaccess. My **.htaccess**: ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /blog/ RewriteRule ^index\.php$ - [L]...
wp-admin-canonical is [broken](https://core.trac.wordpress.org/ticket/35561), as it assumes how WordPress is installed. there was a plugin to fix it, but the plugin was removed from the plugin repository apparently. It is still on github and pluginmirror though: <https://github.com/wp-plugins/remove-wp-canonical-url-a...
240,678
<p>I have a really odd issue:</p> <ol> <li>I have a WP site, staging and live are on the same server.</li> <li>Query string variables aren't registering in the $_GET or $_REQUEST arrays on the live site (but they are on staging). Code in the same place, where QS vars are needed, dumping $_REQUEST, gives the vars as ex...
[ { "answer_id": 240754, "author": "bosco", "author_id": 25324, "author_profile": "https://wordpress.stackexchange.com/users/25324", "pm_score": 2, "selected": false, "text": "<p>Missing GET request variables are sometimes a symptom of improper rewrite rules in the web-server's configurati...
2016/09/27
[ "https://wordpress.stackexchange.com/questions/240678", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2336/" ]
I have a really odd issue: 1. I have a WP site, staging and live are on the same server. 2. Query string variables aren't registering in the $\_GET or $\_REQUEST arrays on the live site (but they are on staging). Code in the same place, where QS vars are needed, dumping $\_REQUEST, gives the vars as expected on stagin...
Missing GET request variables are sometimes a symptom of improper rewrite rules in the web-server's configuration files. In the case of Apache, rewrites are most often implemented using the [`mod_rewrite`](http://httpd.apache.org/docs/current/mod/mod_rewrite.html) module's directives in the WordPress installation's dir...