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
258,053
<p>I am using Remove product-category slug plugin works with 1 subcategroy not with 2. Like:</p> <pre><code>www.domain.com/europe/netherlands/amsterdam (doesn't work) www.domain.com/product-categorie/europe/netherlands/amsterdam (work) www.domain.com/europe/netherlands (work) www.domain.com/product-categorie...
[ { "answer_id": 258032, "author": "Fayaz", "author_id": 110572, "author_profile": "https://wordpress.stackexchange.com/users/110572", "pm_score": 4, "selected": true, "text": "<h1>WordPress way (recommended):</h1>\n\n<p>In your plugin, use the WordPress <code>theme_file_path</code> filter...
2017/02/26
[ "https://wordpress.stackexchange.com/questions/258053", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35917/" ]
I am using Remove product-category slug plugin works with 1 subcategroy not with 2. Like: ``` www.domain.com/europe/netherlands/amsterdam (doesn't work) www.domain.com/product-categorie/europe/netherlands/amsterdam (work) www.domain.com/europe/netherlands (work) www.domain.com/product-categorie/europe/nether...
WordPress way (recommended): ============================ In your plugin, use the WordPress `theme_file_path` filter hook to change the file from the plugin. Use the following CODE in your plugin: ``` add_filter( 'theme_file_path', 'wpse_258026_modify_theme_include_file', 20, 2 ); function wpse_258026_modify_theme_in...
258,055
<p>Lets say I have custom field on post editor, and I change value from <strong>AAA</strong> to <strong>ZZZ</strong>.. :</p> <pre><code>add_action('save_post', function($post){ $value = get_post_meta($post-&gt;ID, 'mykey'); } , 1); </code></pre> <p>How to get the old value (<strong>AAA</strong>) of that...
[ { "answer_id": 258065, "author": "Anwer AR", "author_id": 83820, "author_profile": "https://wordpress.stackexchange.com/users/83820", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p><code>save_post</code> Runs whenever a post or page is created or updated, which\n could be ...
2017/02/26
[ "https://wordpress.stackexchange.com/questions/258055", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33667/" ]
Lets say I have custom field on post editor, and I change value from **AAA** to **ZZZ**.. : ``` add_action('save_post', function($post){ $value = get_post_meta($post->ID, 'mykey'); } , 1); ``` How to get the old value (**AAA**) of that meta-key? during save\_post (even earlier 1st priority), I get **ZZ...
> > `save_post` Runs whenever a post or page is created or updated, which > could be from an import, post/page edit form, xmlrpc, or post by > email. Action function arguments: post ID and post object. Runs after > the data is saved to the database. > > > above paragraph is quoted from WP Codex. so you cannot...
258,094
<p>I have 10 big dropdown select combo boxes of hundreds of font-faces, including System Fonts and Google Fonts. All combo boxes carry the same values.</p> <p>There are two more combo boxes for each of the boxes above, for loading the language and the font-weight sets. These should only be visible/active if the select...
[ { "answer_id": 260629, "author": "ricotheque", "author_id": 34238, "author_profile": "https://wordpress.stackexchange.com/users/34238", "pm_score": 0, "selected": false, "text": "<p>What you can do is add a prefix to each choice <code>key</code> for each Google font, so that your choices...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74107/" ]
I have 10 big dropdown select combo boxes of hundreds of font-faces, including System Fonts and Google Fonts. All combo boxes carry the same values. There are two more combo boxes for each of the boxes above, for loading the language and the font-weight sets. These should only be visible/active if the selected font is...
This question is way too broad for a complete answer in a Q&A format, but here is roughly what I would do: 1. Collect all system fonts in an array `$sys_fonts` 2. Collect all Google fonts in an array `$ggl_fonts` 3. Collect the [complete info about Google fonts](https://developers.google.com/fonts/docs/developer_api) ...
258,109
<p>I need the user to be able to sort and filter the posts when viewing a category. The correct way to make a category page would be to use category(-{id}/{slug}).php, but using that automatically creates a loop, so no matter what method I use to sort and filter the posts it will make another loop.</p> <p>In that case...
[ { "answer_id": 258121, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 2, "selected": false, "text": "<p>First of all: Great you're thinking about a wasted query! :)</p>\n\n<p>Second: WP always runs a main query n...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71594/" ]
I need the user to be able to sort and filter the posts when viewing a category. The correct way to make a category page would be to use category(-{id}/{slug}).php, but using that automatically creates a loop, so no matter what method I use to sort and filter the posts it will make another loop. In that case should I ...
Yes, the loop and a specific category template should be used even if you want to customize the query. Why?: 1. Even with a custom page, the main query will run. So with a custom page, you are not actually avoiding the main query, you are only replacing it with a different query. 2. The main query itself is customizab...
258,124
<p>I am trying to create a custom WordPress plugin and I created a new folder inside the "plugins" folder. It's called "wp-services-table". Inside this folder I created two files: wp-services-table.php and wp-services-table-shortcode.php</p> <p>For now the wp-services-table-shortcode.php file is blank. I only wrote th...
[ { "answer_id": 258126, "author": "codiiv", "author_id": 91561, "author_profile": "https://wordpress.stackexchange.com/users/91561", "pm_score": 2, "selected": false, "text": "<p>Could it be that you forgot to comment the <code>Exit if accessed directly</code> part? </p>\n\n<pre><code>//E...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258124", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113047/" ]
I am trying to create a custom WordPress plugin and I created a new folder inside the "plugins" folder. It's called "wp-services-table". Inside this folder I created two files: wp-services-table.php and wp-services-table-shortcode.php For now the wp-services-table-shortcode.php file is blank. I only wrote this in the ...
Could it be that you forgot to comment the `Exit if accessed directly` part? ``` //Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) { exit; } ```
258,156
<p>I'd like to show 4 related posts (without a plugin) at the bottom of my blog. However, I want to exclude a certain category. </p> <p>For example, if my blog post is in category <code>2</code> and <code>3</code>, I want to ignore category <code>2</code> and only look for blog posts of category <code>3</code>. Here i...
[ { "answer_id": 258159, "author": "Rahul", "author_id": 74107, "author_profile": "https://wordpress.stackexchange.com/users/74107", "pm_score": 1, "selected": false, "text": "<p>Give it a go to <code>category__not_in</code> parameter:</p>\n\n<pre><code>$related = get_posts( array(\n 'n...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258156", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94192/" ]
I'd like to show 4 related posts (without a plugin) at the bottom of my blog. However, I want to exclude a certain category. For example, if my blog post is in category `2` and `3`, I want to ignore category `2` and only look for blog posts of category `3`. Here is the relevant part of `single.php`: ***Note:*** my c...
What I could gather from your question is: 1. You want to ignore one category (may be more) in the related post query. 2. However, you don't want to actually exclude the posts from that category (in case any post belongs to that category, but also belongs to another category you want to look for). Based on the assump...
258,157
<p>I have a custom search query which I have put in a plugin. The homepage has a custom search form and when the user searches for something, it goes to the search page and displays the result.</p> <p>My issue is that the custom query runs on every page of the website, even in the admin panel. It keeps throwing the er...
[ { "answer_id": 258161, "author": "Anwer AR", "author_id": 83820, "author_profile": "https://wordpress.stackexchange.com/users/83820", "pm_score": 0, "selected": false, "text": "<p>try adding more conditional checks as required.</p>\n\n<pre><code>if ( is_search() &amp;&amp; ! is_admin &am...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258157", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/447/" ]
I have a custom search query which I have put in a plugin. The homepage has a custom search form and when the user searches for something, it goes to the search page and displays the result. My issue is that the custom query runs on every page of the website, even in the admin panel. It keeps throwing the error `latit...
You are missing the curly brackets `{}` around your query statements so the query is modified regardless of the `if` statement. So try modifying your code to have something like ``` if( is_search() ) { $fields = '...'; return $fields } ``` same thing with your `$join` variable Remember that while using `i...
258,165
<p>In my situation, WordPress was using the wrong url in sortable column headers, filters and pagination in the admin dashboard. The only solution that worked involved modifying core files, specifically lines 767 and 1053, where I had to change</p> <pre><code>$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_H...
[ { "answer_id": 258161, "author": "Anwer AR", "author_id": 83820, "author_profile": "https://wordpress.stackexchange.com/users/83820", "pm_score": 0, "selected": false, "text": "<p>try adding more conditional checks as required.</p>\n\n<pre><code>if ( is_search() &amp;&amp; ! is_admin &am...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258165", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/108817/" ]
In my situation, WordPress was using the wrong url in sortable column headers, filters and pagination in the admin dashboard. The only solution that worked involved modifying core files, specifically lines 767 and 1053, where I had to change ``` $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERV...
You are missing the curly brackets `{}` around your query statements so the query is modified regardless of the `if` statement. So try modifying your code to have something like ``` if( is_search() ) { $fields = '...'; return $fields } ``` same thing with your `$join` variable Remember that while using `i...
258,183
<p>I am using Twitter Intents as part of my theme and I can successfully share posts’ URLs on Twitter. However, I would like to be able to show the images of the shared posts. Is that even possible? I was thinking to make use of Twitter cards: <a href="https://dev.twitter.com/cards/overview" rel="nofollow noreferrer">h...
[ { "answer_id": 258344, "author": "brianjohnhanna", "author_id": 65403, "author_profile": "https://wordpress.stackexchange.com/users/65403", "pm_score": 1, "selected": false, "text": "<p>Yes, what you want to implement is cards. This is basically the concept of injecting metadata into you...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258183", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29402/" ]
I am using Twitter Intents as part of my theme and I can successfully share posts’ URLs on Twitter. However, I would like to be able to show the images of the shared posts. Is that even possible? I was thinking to make use of Twitter cards: <https://dev.twitter.com/cards/overview> Is that a viable solution? I guess I a...
I have ended up with the following: ``` function my_twitter_cards() { if (is_singular()) { global $post; $twitter_user = str_replace('@', '', get_the_author_meta('twitter')); $twitter_url = get_permalink(); $twitter_title = get_the_title(); $twitter_excerpt = get_the_excerpt(); $twitter...
258,188
<p>I'm using the code below to upload a post thumbnail image through the front end. However, it only seems to upload the original size and not all the various thumbnail sizes e.g. 'medium', 'large' etc. I am getting <code>_wp_attached_file</code> and <code>_thumbnail_id</code> entered into the db no problem, but no oth...
[ { "answer_id": 258197, "author": "The Sumo", "author_id": 76021, "author_profile": "https://wordpress.stackexchange.com/users/76021", "pm_score": 0, "selected": false, "text": "<p>It seems that the only way to do this is to use <a href=\"https://codex.wordpress.org/Function_Reference/med...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258188", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76021/" ]
I'm using the code below to upload a post thumbnail image through the front end. However, it only seems to upload the original size and not all the various thumbnail sizes e.g. 'medium', 'large' etc. I am getting `_wp_attached_file` and `_thumbnail_id` entered into the db no problem, but no other size meta data. The im...
wp\_generate\_attachment\_metadata generates metadata for an image attachment. It also creates a thumbnail and other intermediate sizes of the image attachment based on the sizes defined on the Settings\_Media\_Screen. wp\_generate\_attachment\_metadata() is located in wp-admin/includes/image.php. /\* just require im...
258,190
<p>I have the following function written, the issue is when I set the category in my shortcode it ignores it and shows all posts from the custom post type. So it only sort of works.</p> <pre><code>/*-------------------------------------------------------------- ## Resources Shortcode ----------------------------------...
[ { "answer_id": 258197, "author": "The Sumo", "author_id": 76021, "author_profile": "https://wordpress.stackexchange.com/users/76021", "pm_score": 0, "selected": false, "text": "<p>It seems that the only way to do this is to use <a href=\"https://codex.wordpress.org/Function_Reference/med...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258190", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96257/" ]
I have the following function written, the issue is when I set the category in my shortcode it ignores it and shows all posts from the custom post type. So it only sort of works. ``` /*-------------------------------------------------------------- ## Resources Shortcode ------------------------------------------------...
wp\_generate\_attachment\_metadata generates metadata for an image attachment. It also creates a thumbnail and other intermediate sizes of the image attachment based on the sizes defined on the Settings\_Media\_Screen. wp\_generate\_attachment\_metadata() is located in wp-admin/includes/image.php. /\* just require im...
258,192
<p>I am trying to allow CSV files in a dashboard menu page like this..</p> <pre><code>&lt;form method="post" enctype="multipart/form-data"&gt; &lt;input type="file" name="csv_file" id="csv_file" multiple="false" accept=".csv" /&gt; &lt;input type="submit" value="Upload" /&gt; &lt;/form&gt; require_once( ABS...
[ { "answer_id": 258198, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": false, "text": "<p>By default, WordPress blocks <code>.csv</code> file uploads. The <code>mime_types</code> filter will allow ...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258192", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10247/" ]
I am trying to allow CSV files in a dashboard menu page like this.. ``` <form method="post" enctype="multipart/form-data"> <input type="file" name="csv_file" id="csv_file" multiple="false" accept=".csv" /> <input type="submit" value="Upload" /> </form> require_once( ABSPATH . 'wp-admin/includes/file.php' ); ...
There's a [bug](https://wordpress.org/support/topic/read-this-first-wordpress-4-7-master-list/?view=all#post-8521428) in WordPress 4.7-4.7.3 related to validating MIME types, so the code provided by Dave Romsey won't work. There's a [plugin in the repo](https://wordpress.org/plugins/disable-real-mime-check/) that will...
258,199
<p>I added HTML banners to the top of certain pages on a client's site. He wants to make edits to the text phrases on these banners without having to edit any HTML. How do I open this up for him? <hr> In the past, I have simply made a collection of pages that I insert into my HTML banners using the following code:</p> ...
[ { "answer_id": 258204, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 3, "selected": true, "text": "<p>Are the banners related to each page? If so, I would use a custom field or just a metabox that the user could ...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258199", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27503/" ]
I added HTML banners to the top of certain pages on a client's site. He wants to make edits to the text phrases on these banners without having to edit any HTML. How do I open this up for him? --- In the past, I have simply made a collection of pages that I insert into my HTML banners using the following code: ``` <...
Are the banners related to each page? If so, I would use a custom field or just a metabox that the user could edit or enter information into on the page that you want the banner to show up. The field would show up below the content in the page editor. You would then in your single.php add the code you noted above to en...
258,207
<p>I want to hide a widget completely when a visitor is using an ipad on <code>portrait orientation</code> (768x1024).</p> <p>I know that the media query will be this:</p> <pre><code>@media (width: 768px) and (height: 1024px) { .nameofthewidgetclass { display: none; } } </code></pre> <p>But I have two issues.</p>...
[ { "answer_id": 258204, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 3, "selected": true, "text": "<p>Are the banners related to each page? If so, I would use a custom field or just a metabox that the user could ...
2017/02/27
[ "https://wordpress.stackexchange.com/questions/258207", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114346/" ]
I want to hide a widget completely when a visitor is using an ipad on `portrait orientation` (768x1024). I know that the media query will be this: ``` @media (width: 768px) and (height: 1024px) { .nameofthewidgetclass { display: none; } } ``` But I have two issues. 1) I am not 100% sure how to target the specif...
Are the banners related to each page? If so, I would use a custom field or just a metabox that the user could edit or enter information into on the page that you want the banner to show up. The field would show up below the content in the page editor. You would then in your single.php add the code you noted above to en...
258,210
<p>I create shortcode like this</p> <pre><code>function test_func( $atts ) { return $_GET['myvar']; } add_shortcode( 'test', 'test_func' ); </code></pre> <p>and one page with this name myparameters</p> <p>so this is the final url </p> <pre><code>http://website.com/myparameters </code></pre> <p>if I try th...
[ { "answer_id": 258204, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 3, "selected": true, "text": "<p>Are the banners related to each page? If so, I would use a custom field or just a metabox that the user could ...
2017/02/28
[ "https://wordpress.stackexchange.com/questions/258210", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68371/" ]
I create shortcode like this ``` function test_func( $atts ) { return $_GET['myvar']; } add_shortcode( 'test', 'test_func' ); ``` and one page with this name myparameters so this is the final url ``` http://website.com/myparameters ``` if I try this works perfect ``` http://website.com/myparameters/?m...
Are the banners related to each page? If so, I would use a custom field or just a metabox that the user could edit or enter information into on the page that you want the banner to show up. The field would show up below the content in the page editor. You would then in your single.php add the code you noted above to en...
258,223
<p>I wrote a repeater script that clones the last field group before it. My issue is that cloned WP Color Picker fields don't open the new color spectrum when clicked on but instead opens the color picker in the group it was cloned from.</p> <p>Of course, it works fine once you save the field and reload the page, but ...
[ { "answer_id": 258274, "author": "Paul 'Sparrow Hawk' Biron", "author_id": 113496, "author_profile": "https://wordpress.stackexchange.com/users/113496", "pm_score": 1, "selected": false, "text": "<p>It's hard to know for sure, since you don't include the markup you're output for the meta...
2017/02/28
[ "https://wordpress.stackexchange.com/questions/258223", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14649/" ]
I wrote a repeater script that clones the last field group before it. My issue is that cloned WP Color Picker fields don't open the new color spectrum when clicked on but instead opens the color picker in the group it was cloned from. Of course, it works fine once you save the field and reload the page, but not on the...
It's hard to know for sure, since you don't include the markup you're output for the metabox nor the JS you're using to clone. But, the following simplified setup seems to work for me: **metabox markup** ``` <label for='my_field'> My Color Picker Field </label> <input name='my_field' id='my_field' type='text' cla...
258,269
<p>I'm looking for a way to remove the Section <code>font_selection</code> and move the Control <code>body_font_family</code> straight to the Panel <code>font_panel</code> using Child Theme <code>functions.php</code>. Below is the sample CODE from parent theme's <code>customizer.php</code>:</p> <pre><code>//PANEL $wp_...
[ { "answer_id": 258477, "author": "Weston Ruter", "author_id": 8521, "author_profile": "https://wordpress.stackexchange.com/users/8521", "pm_score": 1, "selected": false, "text": "<p>Assuming that the parent theme is running the above code at <code>customize_register</code> priority 10, y...
2017/02/28
[ "https://wordpress.stackexchange.com/questions/258269", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113957/" ]
I'm looking for a way to remove the Section `font_selection` and move the Control `body_font_family` straight to the Panel `font_panel` using Child Theme `functions.php`. Below is the sample CODE from parent theme's `customizer.php`: ``` //PANEL $wp_customize->add_panel( 'font_panel', array( 'priority' => 17...
Assuming that the parent theme is running the above code at `customize_register` priority 10, you just have to add another `customize_register` action callback that runs afterward, like at 20. However, you cannot move a control to a *panel*. Controls can only reside inside of *sections*. To move a control to another se...
258,277
<p>When doing a template such as single.php and you have php wrapped in html, is it best to :</p> <ol> <li><p>Start + Stop PHP? for example</p> <pre><code> &lt;h1 class="post-tilte"&gt;&lt;?php the_title(); ?&gt;&lt;/h1&gt; &lt;p class="post-content"&gt;&lt;?php the_content();?&gt;&lt;/p&gt; </code></pre></li> </ol>...
[ { "answer_id": 258283, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 3, "selected": false, "text": "<p>That's question is only relevant, because WordPress use a mix from a coding language and layout language. If you ...
2017/02/28
[ "https://wordpress.stackexchange.com/questions/258277", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102774/" ]
When doing a template such as single.php and you have php wrapped in html, is it best to : 1. Start + Stop PHP? for example ``` <h1 class="post-tilte"><?php the_title(); ?></h1> <p class="post-content"><?php the_content();?></p> ``` Or 2. Echo HTML and Escape PHP? For example - ``` <?php echo '<h1 class="post-...
That's question is only relevant, because WordPress use a mix from a coding language and layout language. If you would use a template language, syntax, than is this topic not relevant. But to your question. If you use your example source for a Theme, much more layout language like html, then I prefer the first one - it...
258,279
<p>I want to add more classes in the <code>div</code> tag of my search widget. My search is located in the sidebar together with other widgets.</p> <p>My code:</p> <pre><code>function NT_widgets_init() { register_sidebar( array( 'name' =&gt; __( 'Sidebar', 'side' ), 'id' =&gt; 'sidebar', ...
[ { "answer_id": 258292, "author": "Nabil Kadimi", "author_id": 17187, "author_profile": "https://wordpress.stackexchange.com/users/17187", "pm_score": 3, "selected": true, "text": "<p>You have two possible solutions.</p>\n\n<h2>1. The <code>widget_display_callback</code> filter hook</h2>\...
2017/02/28
[ "https://wordpress.stackexchange.com/questions/258279", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93472/" ]
I want to add more classes in the `div` tag of my search widget. My search is located in the sidebar together with other widgets. My code: ``` function NT_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar', 'side' ), 'id' => 'sidebar', 'description' => __( 'Rechte Spal...
You have two possible solutions. 1. The `widget_display_callback` filter hook -------------------------------------------- [This filter hook](http://hookr.io/filters/widget_display_callback/) parameters allows you to target easily the widget instance and override it's arguments. A possible approach would be: Inside ...
258,286
<p>I am developing a wp theme and I want to have a shortcode that can be used serveral times from within an article.</p> <p>in functions.php i have:</p> <pre><code>function twoColPostcardfn($atts, $content){ extract(shortcode_atts(array( 'image'=&gt;'', 'text'=&gt;'', 'title'=&gt;'', ...
[ { "answer_id": 258291, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 1, "selected": false, "text": "<p>It looks like you're adding unnecessary <code>&lt;p&gt;</code> tags around your shortcodes. Try this inst...
2017/02/28
[ "https://wordpress.stackexchange.com/questions/258286", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81925/" ]
I am developing a wp theme and I want to have a shortcode that can be used serveral times from within an article. in functions.php i have: ``` function twoColPostcardfn($atts, $content){ extract(shortcode_atts(array( 'image'=>'', 'text'=>'', 'title'=>'', 'boxlink'=>'', 'flo...
put the remove filter to be called first like this, change your `span` to `div` or you will have issues with some browsers: ``` remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'wpautop' , 12); function twoColPostcardfn($atts, $content){ extract(shortcode_atts(array( 'image'=>'', ...
258,300
<p>I'm querying all child pages on my current page with a custom Query like this.</p> <pre><code>&lt;?php $args = array( 'post_type' =&gt; 'page', 'posts_per_page' =&gt; -1, 'post_parent' =&gt; $post-&gt;ID, 'order' =&gt; 'ASC', 'orderby' =&gt; 'menu_order' ); $subservic...
[ { "answer_id": 258291, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 1, "selected": false, "text": "<p>It looks like you're adding unnecessary <code>&lt;p&gt;</code> tags around your shortcodes. Try this inst...
2017/02/28
[ "https://wordpress.stackexchange.com/questions/258300", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113943/" ]
I'm querying all child pages on my current page with a custom Query like this. ``` <?php $args = array( 'post_type' => 'page', 'posts_per_page' => -1, 'post_parent' => $post->ID, 'order' => 'ASC', 'orderby' => 'menu_order' ); $subservice = new WP_Query( $args ); if ( $su...
put the remove filter to be called first like this, change your `span` to `div` or you will have issues with some browsers: ``` remove_filter( 'the_content', 'wpautop' ); add_filter( 'the_content', 'wpautop' , 12); function twoColPostcardfn($atts, $content){ extract(shortcode_atts(array( 'image'=>'', ...
258,323
<p>I am running on <code>WP 4.7.2</code> and <code>Yoast SEO 4.4</code>. I want to append a PHP variable to all titles. But it seems I am not able to do that. </p> <p>I have read that <code>wp_title</code> used to be the method before WP 4.4, then it was removed, and then it was returned because of some 'bug'?</p> <p...
[ { "answer_id": 258329, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 4, "selected": true, "text": "<p>There's a <code>wpseo_title</code> filter you can hook into. Example:</p>\n\n<pre><code>add_filter('wpseo_...
2017/02/28
[ "https://wordpress.stackexchange.com/questions/258323", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50416/" ]
I am running on `WP 4.7.2` and `Yoast SEO 4.4`. I want to append a PHP variable to all titles. But it seems I am not able to do that. I have read that `wp_title` used to be the method before WP 4.4, then it was removed, and then it was returned because of some 'bug'? I have tried using the `wpseo`+`add_filter` metho...
There's a `wpseo_title` filter you can hook into. Example: ``` add_filter('wpseo_title', 'add_to_page_titles'); function add_to_page_titles($title) { $title .= $addToTitle; return $title; } ```
258,345
<p>First of all thanks for reading, and my apologies for my lack of knowledge.</p> <p>I have a WP site running with a theme and a child theme. I run it in 3 languages Spanish, English and Portuguese; and for handling the translations I'm using WPML plugin.</p> <p>My problem is that in the translated Portfolios and Co...
[ { "answer_id": 258350, "author": "montrealist", "author_id": 8105, "author_profile": "https://wordpress.stackexchange.com/users/8105", "pm_score": 2, "selected": false, "text": "<p>You're absolutely right in your assumption. CSS should <strong>never</strong> be tied to post IDs, because ...
2017/02/28
[ "https://wordpress.stackexchange.com/questions/258345", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114431/" ]
First of all thanks for reading, and my apologies for my lack of knowledge. I have a WP site running with a theme and a child theme. I run it in 3 languages Spanish, English and Portuguese; and for handling the translations I'm using WPML plugin. My problem is that in the translated Portfolios and Contact page the si...
You're absolutely right in your assumption. CSS should **never** be tied to post IDs, because they can always change (for example if you decide to migrate your posts to another install). You can always shift control towards the admin dashboard. Add a custom field in a post/page that you want styled in a special way (...
258,358
<p>So i'm new at wordpress, I want to add some php code in my home page, but I don't understand why neither page.php or front-page.php seems to act as a template to my homepage</p> <p>I tried to copy front-page.php and I put</p> <pre><code>/** * Template Name: homepagetemplate **/ </code></pre> <p>edited the html a...
[ { "answer_id": 258350, "author": "montrealist", "author_id": 8105, "author_profile": "https://wordpress.stackexchange.com/users/8105", "pm_score": 2, "selected": false, "text": "<p>You're absolutely right in your assumption. CSS should <strong>never</strong> be tied to post IDs, because ...
2017/02/28
[ "https://wordpress.stackexchange.com/questions/258358", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114425/" ]
So i'm new at wordpress, I want to add some php code in my home page, but I don't understand why neither page.php or front-page.php seems to act as a template to my homepage I tried to copy front-page.php and I put ``` /** * Template Name: homepagetemplate **/ ``` edited the html and add some super-big Text to see...
You're absolutely right in your assumption. CSS should **never** be tied to post IDs, because they can always change (for example if you decide to migrate your posts to another install). You can always shift control towards the admin dashboard. Add a custom field in a post/page that you want styled in a special way (...
258,362
<p>Variations of this question have been asked, however the scenarios do not match mine and despite my efforts I have not been able to adopt the previous answers to a working solution in my use case.</p> <p>I have a page template that has a javascript application built into it. This application uses the last parameter...
[ { "answer_id": 258369, "author": "filipecsweb", "author_id": 84657, "author_profile": "https://wordpress.stackexchange.com/users/84657", "pm_score": 0, "selected": false, "text": "<p>You might be able to solve your problem just by changing your rewrite rule to:</p>\n\n<p><code>RewriteRul...
2017/03/01
[ "https://wordpress.stackexchange.com/questions/258362", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/97943/" ]
Variations of this question have been asked, however the scenarios do not match mine and despite my efforts I have not been able to adopt the previous answers to a working solution in my use case. I have a page template that has a javascript application built into it. This application uses the last parameter in a URL ...
You can use an internal rewrite instead of .htaccess: ``` function wpd_service_rewrite() { add_rewrite_rule( '^service/testing-tool/([a-z0-9.]+)$', 'index.php?pagename=service/results', 'top' ); } add_action( 'init', 'wpd_service_rewrite' ); ``` Don't forget to [flush rewrite rules](h...
258,364
<p>I am in the process of putting together my own WordPress Theme. Up until now, I have been using the 'single.php' file to act as a Template for both my Blogs and Media Files. In reference to my Media files, I have been using the <code>&lt;?php the_content(); ?&gt;</code> tag to call such images. </p> <p>I have no...
[ { "answer_id": 258369, "author": "filipecsweb", "author_id": 84657, "author_profile": "https://wordpress.stackexchange.com/users/84657", "pm_score": 0, "selected": false, "text": "<p>You might be able to solve your problem just by changing your rewrite rule to:</p>\n\n<p><code>RewriteRul...
2017/03/01
[ "https://wordpress.stackexchange.com/questions/258364", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112472/" ]
I am in the process of putting together my own WordPress Theme. Up until now, I have been using the 'single.php' file to act as a Template for both my Blogs and Media Files. In reference to my Media files, I have been using the `<?php the_content(); ?>` tag to call such images. I have now reached the stage, where I h...
You can use an internal rewrite instead of .htaccess: ``` function wpd_service_rewrite() { add_rewrite_rule( '^service/testing-tool/([a-z0-9.]+)$', 'index.php?pagename=service/results', 'top' ); } add_action( 'init', 'wpd_service_rewrite' ); ``` Don't forget to [flush rewrite rules](h...
258,401
<p>I have registered a sidebar with the following code :</p> <pre><code>function reg_l_sid(){ $args = array( 'name' =&gt; __( 'left-sidebar', 'Tutorial-Blog' ), 'id' =&gt; 'left-sidebar', 'description' =&gt; '', 'class' =&gt; '', 'before_widget' =&gt; '&lt;li...
[ { "answer_id": 258402, "author": "Sonali", "author_id": 84167, "author_profile": "https://wordpress.stackexchange.com/users/84167", "pm_score": 3, "selected": true, "text": "<p>Please try this one,because without id we i don't think that will work:</p>\n\n<pre><code> function reg_l_sid(...
2017/03/01
[ "https://wordpress.stackexchange.com/questions/258401", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102224/" ]
I have registered a sidebar with the following code : ``` function reg_l_sid(){ $args = array( 'name' => __( 'left-sidebar', 'Tutorial-Blog' ), 'id' => 'left-sidebar', 'description' => '', 'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">'...
Please try this one,because without id we i don't think that will work: ``` function reg_l_sid() { $args = array( 'id' => 'sidebar-footer-6','name'=> 'Left-sidebar'); register_sidebar($args); } add_action('widgets_init', 'reg_l_sid'); ``` and inside template: ``` if (is_active_sidebar('sidebar-foote...
258,434
<p>Currently i am using this code to output menu display :</p> <pre><code>&lt;?php wp_nav_menu(array( 'theme_location' =&gt; 'songs-category', 'container' =&gt; false, 'menu_id' =&gt; 'nav', 'menu_class' =&gt; '', 'items_wrap' =&gt; '&lt;ul id="nav"&gt;&lt;li class="active"&gt;&lt;a href="#" data-...
[ { "answer_id": 258440, "author": "ajie", "author_id": 114369, "author_profile": "https://wordpress.stackexchange.com/users/114369", "pm_score": 2, "selected": false, "text": "<p>You will have to use a custom Walker for your menu. Here is the page in the codex that explains it: </p>\n\n<p...
2017/03/01
[ "https://wordpress.stackexchange.com/questions/258434", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114481/" ]
Currently i am using this code to output menu display : ``` <?php wp_nav_menu(array( 'theme_location' => 'songs-category', 'container' => false, 'menu_id' => 'nav', 'menu_class' => '', 'items_wrap' => '<ul id="nav"><li class="active"><a href="#" data-slug="4,5,6,7,8,9" class="xyz">All</a></li>%3$s...
You will have to use a custom Walker for your menu. Here is the page in the codex that explains it: <https://codex.wordpress.org/Class_Reference/Walker> and here: <https://developer.wordpress.org/reference/classes/walker_nav_menu/> Hope that helps.
258,437
<p>I am trying to automate the change in order status from "on-hold" to "pending payment" once a product vendor has marked an order as fulfilled. Currently, the default status in "on-hold" when an order is created and only once the product is delivered must payment be required. Is it possible to update to the "pending"...
[ { "answer_id": 258443, "author": "Sonali", "author_id": 84167, "author_profile": "https://wordpress.stackexchange.com/users/84167", "pm_score": -1, "selected": false, "text": "<p>Yes you just add see when you want to change status and add inside this function.</p>\n\n<pre><code> add_ac...
2017/03/01
[ "https://wordpress.stackexchange.com/questions/258437", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114482/" ]
I am trying to automate the change in order status from "on-hold" to "pending payment" once a product vendor has marked an order as fulfilled. Currently, the default status in "on-hold" when an order is created and only once the product is delivered must payment be required. Is it possible to update to the "pending" st...
If you ever need to change the order status from php here is how to do it. ``` $order = new WC_Order($order_id); if (!empty($order)) { $order->update_status( 'completed' ); } ``` Possible values: processing, on-hold, cancelled, completed This is from woocommerce/includes/abstracts/abstract-wc-order.php
258,457
<p>I have a custom post type and using this function to add for posts, previous and next buttons. </p> <p>The problem is that within the custom post type, I have subcategories defined by a custom field <code>category</code>. </p> <p>Is there a way to limit the previous and next post link for items only within the sam...
[ { "answer_id": 258468, "author": "TrubinE", "author_id": 111011, "author_profile": "https://wordpress.stackexchange.com/users/111011", "pm_score": 0, "selected": false, "text": "<p>This function must be used within the loop.</p>\n\n<p><a href=\"https://codex.wordpress.org/Function_Refere...
2017/03/01
[ "https://wordpress.stackexchange.com/questions/258457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40727/" ]
I have a custom post type and using this function to add for posts, previous and next buttons. The problem is that within the custom post type, I have subcategories defined by a custom field `category`. Is there a way to limit the previous and next post link for items only within the same category of the current po...
You want to change the `in_same_term` value to TRUE as follows: ``` function crunchify_post_navigation(){ ?> <div class="arrowNav"> <div class="arrowLeft"> <?php previous_post_link('%link', '&#8606;', TRUE); ?> </div> <div class="arrowRight"> <?php next_post_lin...
258,482
<p>I'm trying, without success, to disable pagination only in a specific category (where I'm showing all the posts of that category listed by years). Someone can help me? Thanks.</p>
[ { "answer_id": 258483, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 2, "selected": false, "text": "<p>You can try this, replacing <code>my_cat</code> with your category slug. This will modify the main query j...
2017/03/01
[ "https://wordpress.stackexchange.com/questions/258482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113631/" ]
I'm trying, without success, to disable pagination only in a specific category (where I'm showing all the posts of that category listed by years). Someone can help me? Thanks.
You can try this, replacing `my_cat` with your category slug. This will modify the main query just before rendering the loop on the archive page of your category. ``` add_action( 'pre_get_posts', 'wpse_disable_pagination' ); function wpse_disable_pagination( $query ) { if( is_category( 'my_cat' ) { query->set( ...
258,491
<p>I've created custom post types in a theme before (actually on the exact theme I'm having trouble with now), and everything has gone relatively seamlessly. However, now I've run into an issue where a post type that I'm trying to create, with archive and content php files, is not working. More specifically, the slug i...
[ { "answer_id": 258483, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 2, "selected": false, "text": "<p>You can try this, replacing <code>my_cat</code> with your category slug. This will modify the main query j...
2017/03/01
[ "https://wordpress.stackexchange.com/questions/258491", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100731/" ]
I've created custom post types in a theme before (actually on the exact theme I'm having trouble with now), and everything has gone relatively seamlessly. However, now I've run into an issue where a post type that I'm trying to create, with archive and content php files, is not working. More specifically, the slug is n...
You can try this, replacing `my_cat` with your category slug. This will modify the main query just before rendering the loop on the archive page of your category. ``` add_action( 'pre_get_posts', 'wpse_disable_pagination' ); function wpse_disable_pagination( $query ) { if( is_category( 'my_cat' ) { query->set( ...
258,506
<p>I have set up the following:</p> <pre><code>add_image_size( 'featured-image', 1600, 450, true ); </code></pre> <p>which is used to serve a full width image on the website I'm building, but, as you can imagine, for mobile this is re-scaled to a ridiculously small height and looks really odd on mobile.</p> <p>I hav...
[ { "answer_id": 258530, "author": "Fernando Baltazar", "author_id": 10218, "author_profile": "https://wordpress.stackexchange.com/users/10218", "pm_score": -1, "selected": false, "text": "<p>You need to do a conditional (if) to change or select the part for big devices or mobile, if you w...
2017/03/01
[ "https://wordpress.stackexchange.com/questions/258506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114518/" ]
I have set up the following: ``` add_image_size( 'featured-image', 1600, 450, true ); ``` which is used to serve a full width image on the website I'm building, but, as you can imagine, for mobile this is re-scaled to a ridiculously small height and looks really odd on mobile. I have created a new image size which ...
WordPress `wp_is_mobile()` can be the function that you're looking for. ``` // Use the build-in function if WP if(wp_is_mobile()) // On mobile { the_post_thumbnail_url('featured-image-mobile'); } else { the_post_thumbnail_url('featured-image'); } ```
258,510
<p>I spent a lot of time searching for a solution where I can pass the value of the JavaScript variable into PHP variable in the same file, same function (WordPress Widget, Form function). Is there a good way, as of 2017, to do so?</p> <p>I have tried this method below. Although the Ajax part bring out the successful ...
[ { "answer_id": 258512, "author": "xvilo", "author_id": 104427, "author_profile": "https://wordpress.stackexchange.com/users/104427", "pm_score": 1, "selected": false, "text": "<p>Please remember that the code fires from top to bottom. </p>\n\n<p>This way you <strong>can not</strong> 'get...
2017/03/01
[ "https://wordpress.stackexchange.com/questions/258510", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113869/" ]
I spent a lot of time searching for a solution where I can pass the value of the JavaScript variable into PHP variable in the same file, same function (WordPress Widget, Form function). Is there a good way, as of 2017, to do so? I have tried this method below. Although the Ajax part bring out the successful message, t...
I found an easy way to pass a JavaScript variable to PHP variable. Please note that this method works in WordPress version 4.7.2, and only specifically on Widget. I wrote a lot of comments to try to explain what each line did. If you have a better solution, please share with us! **Solution:** * Create a hidden input...
258,525
<p>In my website currently for every new registration. New registered user is receiving their credential i.e., username and password in there email.</p> <p>I want to allow the user to set their password at the time of registration and after that an email verification link will sent to their email id.</p> <p>Below is ...
[ { "answer_id": 258526, "author": "Fernando Baltazar", "author_id": 10218, "author_profile": "https://wordpress.stackexchange.com/users/10218", "pm_score": 4, "selected": true, "text": "<p>Well, you can create your own login form which I´ve have done also few years ago, but it is easier t...
2017/03/02
[ "https://wordpress.stackexchange.com/questions/258525", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106282/" ]
In my website currently for every new registration. New registered user is receiving their credential i.e., username and password in there email. I want to allow the user to set their password at the time of registration and after that an email verification link will sent to their email id. Below is my code which i w...
Well, you can create your own login form which I´ve have done also few years ago, but it is easier to do it with a plugin. there are a lot of these plugins, for example: **Auto login new user** <https://wordpress.org/plugins/auto-login-new-user-after-registration/>; also you can add **social login** to your Wordpress, ...
258,529
<p>i have installed word press + woo commerce, my site is running in Arabic language. </p> <p>my check out page is contain these fields (first name - last name - E-mail - phone) </p> <p>what i want: i hope to edit my checkout page by adding an extra fields like (Company name - position) how to do this </p> <p>i ho...
[ { "answer_id": 258533, "author": "Fernando Baltazar", "author_id": 10218, "author_profile": "https://wordpress.stackexchange.com/users/10218", "pm_score": 0, "selected": false, "text": "<p>Try to use a plugin to acheive this. there are several plugins on repository <a href=\"https://word...
2017/03/02
[ "https://wordpress.stackexchange.com/questions/258529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114524/" ]
i have installed word press + woo commerce, my site is running in Arabic language. my check out page is contain these fields (first name - last name - E-mail - phone) what i want: i hope to edit my checkout page by adding an extra fields like (Company name - position) how to do this i hope if you explain me i di...
If you at least know how to open your "functions.php" file, the following should work if you simply add it at the bottom of your functions.php file of your (child-)theme: ``` // Hook in add_filter( 'woocommerce_checkout_fields' , 'custom_add_checkout_fields' ); // Our hooked in function - $fields is passed via the f...
258,541
<p>I tried echoing <code>get_the_excerpt(1)</code>, on different locations outside the loops:</p> <ul> <li>somewhere in <code>footer.php</code></li> <li>somewhere in <code>header.php</code></li> </ul> <p>(The post with ID 1 has no defined excerpt btw, so I was hoping for the auto-generated ones to came out)</p> <hr>...
[ { "answer_id": 258550, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 0, "selected": false, "text": "<p>Outside the loop you could try something like this:</p>\n\n<pre><code>$post_id = 1;\n$myexcerpt = apply_filter...
2017/03/02
[ "https://wordpress.stackexchange.com/questions/258541", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114526/" ]
I tried echoing `get_the_excerpt(1)`, on different locations outside the loops: * somewhere in `footer.php` * somewhere in `header.php` (The post with ID 1 has no defined excerpt btw, so I was hoping for the auto-generated ones to came out) --- The one in `footer.php` printed the stuff just fine, but the one in `he...
So you are basically also looking for a fallback in case your excerpt is empty? I suppose this question/answer could be helpful for you: "[get\_the\_excerpt() with fallback like the\_excerpt()](https://wordpress.stackexchange.com/questions/87620/get-the-excerpt-with-fallback-like-the-excerpt)". It describes, how to bui...
258,573
<p>I'm working on WordPress website locally and I'm using Git. I followed this tutorial <a href="http://www.designcollective.io/blogs/manage-wordpress-with-git" rel="nofollow noreferrer">http://www.designcollective.io/blogs/manage-wordpress-with-git</a> and everything works fine on localhost. I moved my website to serv...
[ { "answer_id": 258576, "author": "Elex", "author_id": 113687, "author_profile": "https://wordpress.stackexchange.com/users/113687", "pm_score": 0, "selected": false, "text": "<p>Can you show us your directory and your <code>.htaccess</code> file ?\nTo be honest, moving the wp-config.php ...
2017/03/02
[ "https://wordpress.stackexchange.com/questions/258573", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113194/" ]
I'm working on WordPress website locally and I'm using Git. I followed this tutorial <http://www.designcollective.io/blogs/manage-wordpress-with-git> and everything works fine on localhost. I moved my website to server, changed database name etc. And homepage works fine but I can't log into wp-admin. It gives me this: ...
Tried to solve the problem on my own. I changed structure to typical wordpress installation but it didn't help. So I deleted wordpress, cleaned database, installed wordpress again and manually moved my theme to Wordpress. Now everything works fine.
258,592
<p>I am trying to use the .htaccess file to restrict access to the wp-admin directory to an IP range as prescribed <a href="https://codex.wordpress.org/Brute_Force_Attacks#Limit_Access_to_wp-admin_by_IP" rel="nofollow noreferrer">here</a></p> <pre><code># Block access to wp-admin. order deny,allow allow from x.x.x.* d...
[ { "answer_id": 258603, "author": "C C", "author_id": 83299, "author_profile": "https://wordpress.stackexchange.com/users/83299", "pm_score": 0, "selected": false, "text": "<pre><code>order deny,allow\ndeny from all\nallow from x.x.x \n</code></pre>\n\n<p>or</p>\n\n<pre><code>order deny,a...
2017/03/02
[ "https://wordpress.stackexchange.com/questions/258592", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114569/" ]
I am trying to use the .htaccess file to restrict access to the wp-admin directory to an IP range as prescribed [here](https://codex.wordpress.org/Brute_Force_Attacks#Limit_Access_to_wp-admin_by_IP) ``` # Block access to wp-admin. order deny,allow allow from x.x.x.* deny from all' ``` **It does precisely nothing:**...
I have traced the problem to a set of directions in the .conf file: the Virtual Host was missing this: ``` <Directory "/var/www"> AllowOverride All </Directory> ``` Which made the server to ignore .htaccess files altogether. The full answer is [here](https://askubuntu.com/questions/429869/is-this-a-correct-way-to-e...
258,615
<p>I need to add custom links, on the fly, to the navigation menu. I can add custom links to the first level of items (created via Appearance > Menus), but for some reason, I cannot add a custom link, child of another custom link create previously.. </p> <p>Here's my code:</p> <pre><code>function on_the_fly($items) ...
[ { "answer_id": 258626, "author": "WPExplorer", "author_id": 68694, "author_profile": "https://wordpress.stackexchange.com/users/68694", "pm_score": 2, "selected": false, "text": "<p>There is a really good example on this page if you want to have a look and see if it helps - <a href=\"htt...
2017/03/02
[ "https://wordpress.stackexchange.com/questions/258615", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56387/" ]
I need to add custom links, on the fly, to the navigation menu. I can add custom links to the first level of items (created via Appearance > Menus), but for some reason, I cannot add a custom link, child of another custom link create previously.. Here's my code: ``` function on_the_fly($items) { $menu_items = ...
There is a really good example on this page if you want to have a look and see if it helps - <https://isabelcastillo.com/dynamically-sub-menu-item-wp_nav_menu>
258,616
<p>Im brand new to coding in wordpress, usually I use ModX. In ModX there is a plugin called phpthumb which automatically crops images to a specified h and w. How can I achieve this in Wordpress?</p> <p>Image Code:</p> <pre><code>&lt;?php $thumbnail_id = get_post_thumbnail_id($post-&gt;ID); $thumbnail = wp_get_attach...
[ { "answer_id": 258626, "author": "WPExplorer", "author_id": 68694, "author_profile": "https://wordpress.stackexchange.com/users/68694", "pm_score": 2, "selected": false, "text": "<p>There is a really good example on this page if you want to have a look and see if it helps - <a href=\"htt...
2017/03/02
[ "https://wordpress.stackexchange.com/questions/258616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114585/" ]
Im brand new to coding in wordpress, usually I use ModX. In ModX there is a plugin called phpthumb which automatically crops images to a specified h and w. How can I achieve this in Wordpress? Image Code: ``` <?php $thumbnail_id = get_post_thumbnail_id($post->ID); $thumbnail = wp_get_attachment_image_src($thumbnail_i...
There is a really good example on this page if you want to have a look and see if it helps - <https://isabelcastillo.com/dynamically-sub-menu-item-wp_nav_menu>
258,652
<p>I have custom table where I store quotes and author:</p> <pre><code>function quote_install(){ global $wpdb; global $quote_db_version; $table_name = $wpdb-&gt;prefix . 'quote'; // create sql your table $sql = "CREATE TABLE " . $table_name . " ( ID int(11) NOT NULL AUTO_INCREMENT, time datetime DEF...
[ { "answer_id": 258655, "author": "marwyk87", "author_id": 114372, "author_profile": "https://wordpress.stackexchange.com/users/114372", "pm_score": 0, "selected": false, "text": "<p>I think you might have an syntax problem in your TSQL. If your doing</p>\n\n<pre><code>$table_name = $wpdb...
2017/03/02
[ "https://wordpress.stackexchange.com/questions/258652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112581/" ]
I have custom table where I store quotes and author: ``` function quote_install(){ global $wpdb; global $quote_db_version; $table_name = $wpdb->prefix . 'quote'; // create sql your table $sql = "CREATE TABLE " . $table_name . " ( ID int(11) NOT NULL AUTO_INCREMENT, time datetime DEFAULT '0000-00-00 ...
[Note: @marwyk87 posted his answer while I was composing this, which represents another way to fix the problem] You've got a simple syntax error in your SQL, because of the way you're referencing the table name. You should just say ``` $sql = $wpdb->prepare( " SELECT * FROM {$wpdb->prefix}quotes ORDER BY ...
258,654
<p>I'm doing a project for a web-based app.</p> <p>It is the first time I use wordpress and I have found that I can not edit the template (the "edit" option does not appear in appearance.).</p> <p>And I need to see the files to be able to remove the "hamburger" menu for mobile devices.</p> <p>For now I'm not premmiu...
[ { "answer_id": 258655, "author": "marwyk87", "author_id": 114372, "author_profile": "https://wordpress.stackexchange.com/users/114372", "pm_score": 0, "selected": false, "text": "<p>I think you might have an syntax problem in your TSQL. If your doing</p>\n\n<pre><code>$table_name = $wpdb...
2017/03/02
[ "https://wordpress.stackexchange.com/questions/258654", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114601/" ]
I'm doing a project for a web-based app. It is the first time I use wordpress and I have found that I can not edit the template (the "edit" option does not appear in appearance.). And I need to see the files to be able to remove the "hamburger" menu for mobile devices. For now I'm not premmium. In wix if the option...
[Note: @marwyk87 posted his answer while I was composing this, which represents another way to fix the problem] You've got a simple syntax error in your SQL, because of the way you're referencing the table name. You should just say ``` $sql = $wpdb->prepare( " SELECT * FROM {$wpdb->prefix}quotes ORDER BY ...
258,657
<p>For some reason when doing crawl tests I'm finding pages with the domain name being tacked on the end and causing 404 errors. For example: <a href="http://domainname.com/page-name/http://domainname.com" rel="nofollow noreferrer">http://domainname.com/page-name/http://domainname.com</a></p> <p>This is happening to...
[ { "answer_id": 258655, "author": "marwyk87", "author_id": 114372, "author_profile": "https://wordpress.stackexchange.com/users/114372", "pm_score": 0, "selected": false, "text": "<p>I think you might have an syntax problem in your TSQL. If your doing</p>\n\n<pre><code>$table_name = $wpdb...
2017/03/02
[ "https://wordpress.stackexchange.com/questions/258657", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93558/" ]
For some reason when doing crawl tests I'm finding pages with the domain name being tacked on the end and causing 404 errors. For example: <http://domainname.com/page-name/http://domainname.com> This is happening to all pages, posts and even category type 1. Site is in Wordpress 2. Using Yoast SEO plugin Any sugges...
[Note: @marwyk87 posted his answer while I was composing this, which represents another way to fix the problem] You've got a simple syntax error in your SQL, because of the way you're referencing the table name. You should just say ``` $sql = $wpdb->prepare( " SELECT * FROM {$wpdb->prefix}quotes ORDER BY ...
258,664
<p>I have placed the following Blog Loop into my 'index.php' file:</p> <pre><code>&lt;?php if ( have_posts() ): while( have_posts() ): the_post(); ?&gt; &lt;h3&gt;&lt;?php the_title(); ?&gt;&lt;/h3&gt; &lt;p&gt;&lt;?php the_content(); ?&gt;&lt;/p&gt; &lt;small&gt;This entry was posted on: &lt...
[ { "answer_id": 258667, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 1, "selected": false, "text": "<p>what about surrounding it in the if is_home() statement so it only shows on your blog page?</p>\n\n<pre><code>...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258664", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112472/" ]
I have placed the following Blog Loop into my 'index.php' file: ``` <?php if ( have_posts() ): while( have_posts() ): the_post(); ?> <h3><?php the_title(); ?></h3> <p><?php the_content(); ?></p> <small>This entry was posted on: <?php the_date('l, jS F Y'); ?> at <?php the_time('g:i a'); ?> an...
I have managed to resolve the issue. The code I used, should anyone find themselves in a similar situation, is as follows: ``` <?php if( is_home() ): ?> <h1>Blog Page</h1> <?php endif; ?> <?php if ( have_posts() ): while( have_posts() ): the_post(); ?> <?php if( is_home() ): ?> <h3><a href="<?php t...
258,681
<p>I have create child theme with style.css and functions.css, I edit parts style.css in child theme to get best style. But some page have no effect and style.css from child theme repeated with another version.</p> <p>style.css</p> <pre><code>#masthead { top: 0px; background: black !important; border-top:...
[ { "answer_id": 258667, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 1, "selected": false, "text": "<p>what about surrounding it in the if is_home() statement so it only shows on your blog page?</p>\n\n<pre><code>...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258681", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88507/" ]
I have create child theme with style.css and functions.css, I edit parts style.css in child theme to get best style. But some page have no effect and style.css from child theme repeated with another version. style.css ``` #masthead { top: 0px; background: black !important; border-top: 2px solid rgba(250,1...
I have managed to resolve the issue. The code I used, should anyone find themselves in a similar situation, is as follows: ``` <?php if( is_home() ): ?> <h1>Blog Page</h1> <?php endif; ?> <?php if ( have_posts() ): while( have_posts() ): the_post(); ?> <?php if( is_home() ): ?> <h3><a href="<?php t...
258,694
<p>I want to write a cronjob for myself. But I need to get access to <code>WP_Query</code> and the permissions to delete posts etc.</p> <p>My question now is, how can I include the <code>WP_Query</code> function to my own PHP file and do I need to edit or change some permissions in order to delete or create posts with...
[ { "answer_id": 258697, "author": "Kinna T", "author_id": 97336, "author_profile": "https://wordpress.stackexchange.com/users/97336", "pm_score": 0, "selected": false, "text": "<p>Is this to delete or create sites within a WordPress Multisite environment?\nIf so, you can access WP_Query t...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258694", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114434/" ]
I want to write a cronjob for myself. But I need to get access to `WP_Query` and the permissions to delete posts etc. My question now is, how can I include the `WP_Query` function to my own PHP file and do I need to edit or change some permissions in order to delete or create posts with that cronjob?
Load WordPress in custom PHP Script: ==================================== You need to load essential WordPress core functionality in your custom PHP script for `WP_Query` to work properly. For example, let's say you have a custom PHP file named `my-cron.php` and WordPress is installed in the web root, like this: ```...
258,700
<p>It's since 1 month ago, every day we'll receive some tens of new user registration with username containing like <code>YggrnCyhorgeVH</code> or <code>AurizarCyhorgeVH</code>, etc..</p> <p>Ip and user agent are different every time, so I thinked to avoid user registration with this name.</p> <p><strong>Is there a h...
[ { "answer_id": 258721, "author": "Kristoffer M", "author_id": 113286, "author_profile": "https://wordpress.stackexchange.com/users/113286", "pm_score": 0, "selected": false, "text": "<p>Get spam filters for your site - captcha, Wordfence etc. General security helps against stuff like thi...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258700", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94289/" ]
It's since 1 month ago, every day we'll receive some tens of new user registration with username containing like `YggrnCyhorgeVH` or `AurizarCyhorgeVH`, etc.. Ip and user agent are different every time, so I thinked to avoid user registration with this name. **Is there a hook/action/filter where to intercept the user...
Following code should work for you, but I can not guarantee that because your form is so heavily (and badly) customized. I have tested it on not customized registration form and it worked just fine. ``` function cyhorge_check_fields( $errors, $sanitized_user_login, $user_email ) { if ( preg_match('/(CyhorgeVH)/',...
258,707
<p>I want to add pagination in single page of custom post type.</p> <p>This is the code for single page (custom post type):</p> <pre><code>&lt;?php $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array('post_type' =&gt; 'news', 'posts_per_page' =&gt; 1, 'paged' =&gt; $paged); $loop =...
[ { "answer_id": 258720, "author": "Svartbaard", "author_id": 112928, "author_profile": "https://wordpress.stackexchange.com/users/112928", "pm_score": 0, "selected": false, "text": "<p>The functions</p>\n\n<pre><code>next_posts_link\n</code></pre>\n\n<p>and</p>\n\n<pre><code>previous_post...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258707", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112648/" ]
I want to add pagination in single page of custom post type. This is the code for single page (custom post type): ``` <?php $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array('post_type' => 'news', 'posts_per_page' => 1, 'paged' => $paged); $loop = new WP_Query( $args ); while...
Don't need to start with a new Query in archive.php loop Only need to create a different loop file for the custom taxonomy and default loop post See here for more details [Filtering a custom post type by custom taxonomy in archive template](https://wordpress.stackexchange.com/questions/226923/filtering-a-custom-post-...
258,726
<p>I really read a lot of articles relating adding dynamic inline stylesheet. but this one drives me crazy. i have a simple dev setup. this is my global style:</p> <pre><code>function bootstrap_scripts_styles() { wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri().'/style.css', array(), '2016-07-18' ...
[ { "answer_id": 258724, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": 2, "selected": false, "text": "<p>You need to first understand how WP theme hierarchy works , then only you will be able to find which file you n...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258726", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74101/" ]
I really read a lot of articles relating adding dynamic inline stylesheet. but this one drives me crazy. i have a simple dev setup. this is my global style: ``` function bootstrap_scripts_styles() { wp_enqueue_style( 'custom-style', get_stylesheet_directory_uri().'/style.css', array(), '2016-07-18' ); } add_actio...
You need to first understand how WP theme hierarchy works , then only you will be able to find which file you need to define. Below is the URL to understand how WP theme hierarchy works. <https://developer.wordpress.org/themes/basics/template-hierarchy/>
258,727
<p>I have created 15 post and assigned to the custom taxonomy. It is not displaying all the 15 post. It shows only 10 post.</p> <p>Please guide me. Thanks </p> <pre><code>wp_reset_query(); $args = array( 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'parent_login_gallery', 'fiel...
[ { "answer_id": 258724, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": 2, "selected": false, "text": "<p>You need to first understand how WP theme hierarchy works , then only you will be able to find which file you n...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258727", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/80578/" ]
I have created 15 post and assigned to the custom taxonomy. It is not displaying all the 15 post. It shows only 10 post. Please guide me. Thanks ``` wp_reset_query(); $args = array( 'tax_query' => array( array( 'taxonomy' => 'parent_login_gallery', 'field' => 'term_id', ...
You need to first understand how WP theme hierarchy works , then only you will be able to find which file you need to define. Below is the URL to understand how WP theme hierarchy works. <https://developer.wordpress.org/themes/basics/template-hierarchy/>
258,741
<p>How can I modify the slug for the default wp posts without affecting other posttypes? </p> <p>example: <code>www.example.com/slug-of-post/</code> should become <code>www.example.com/blog/slug-of-post/</code></p> <p>I made a few custom post types where I rewrote the slug by using <code>'rewrite' =&gt; array('slug' ...
[ { "answer_id": 258745, "author": "pouria", "author_id": 101909, "author_profile": "https://wordpress.stackexchange.com/users/101909", "pm_score": 2, "selected": false, "text": "<p>According to the docs: <a href=\"https://codex.wordpress.org/Using_Permalinks\" rel=\"nofollow noreferrer\">...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258741", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112184/" ]
How can I modify the slug for the default wp posts without affecting other posttypes? example: `www.example.com/slug-of-post/` should become `www.example.com/blog/slug-of-post/` I made a few custom post types where I rewrote the slug by using `'rewrite' => array('slug' => 'portfolio'),` in the `function.php` file. ...
According to the docs: <https://codex.wordpress.org/Using_Permalinks> Go to settings -> permalinks -> custom structure and change that to: `/blog/%postname%/` But please make sure that in your custom post types definition, (`register_post_type`) set ``` 'rewrite' => array( 'with_front' => false ), ``` unless t...
258,751
<p>I need to create a custom WordPress admin interface for a client. I want to completely disable the sticky post feature from admin area.</p> <p>I found some posts on the internet that suggest to hide the checkbox using css, but I would really like to disable that feature both from edit and from quick edit screen.</p...
[ { "answer_id": 258763, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": false, "text": "<p>In addition to CSS you could try to unstick each post as soon as it has been made sticky (untested):</p>\n\n<...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258751", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85556/" ]
I need to create a custom WordPress admin interface for a client. I want to completely disable the sticky post feature from admin area. I found some posts on the internet that suggest to hide the checkbox using css, but I would really like to disable that feature both from edit and from quick edit screen. Any ideas?
In addition to CSS you could try to unstick each post as soon as it has been made sticky (untested): ``` add_action( 'post_stuck', function( $post_id ) { unstick_post( $post_id ); } ); ``` If you're looking for another approach, than hiding it from the UI with CSS, then consider using **custom post types** inste...
258,754
<p>When using FormData with Wordpress Admin Ajax I'm only getting back a '0' response. Usually this is because there's no action, however I'm including the action and still have the problem. I've seen similar questions on here but they all assume jQuery is being used, and in my case it isn't.</p> <p>Javascript:</p> <...
[ { "answer_id": 258779, "author": "Spartacus", "author_id": 32329, "author_profile": "https://wordpress.stackexchange.com/users/32329", "pm_score": 1, "selected": false, "text": "<p>FormData is processing the action of your form tag as part of the form data, when that's not what you want ...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258754", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51164/" ]
When using FormData with Wordpress Admin Ajax I'm only getting back a '0' response. Usually this is because there's no action, however I'm including the action and still have the problem. I've seen similar questions on here but they all assume jQuery is being used, and in my case it isn't. Javascript: ``` ...
So it turns out the only problem was the header content type. By removing `request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');` and just leaving it out, it worked fine. That's also with the form action being grabbed and appended. Ajax call: ``` var formData = new FormData(fo...
258,764
<p>Somewhere in the plugin class there is this hook :</p> <p><code>add_action( 'woocommerce_some_hook', array( $this, 'some_function') );</code></p> <p>it adds something I don't want there. In my functions.php in my theme, I have tried everything such as : <code>remove_action('woocommerce_some_hook','some_function')...
[ { "answer_id": 258765, "author": "TrubinE", "author_id": 111011, "author_profile": "https://wordpress.stackexchange.com/users/111011", "pm_score": 0, "selected": false, "text": "<p>It is necessary to pass an instance in which the hook was set up</p>\n\n<pre><code>global $my_class;\nremov...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258764", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111916/" ]
Somewhere in the plugin class there is this hook : `add_action( 'woocommerce_some_hook', array( $this, 'some_function') );` it adds something I don't want there. In my functions.php in my theme, I have tried everything such as : `remove_action('woocommerce_some_hook','some_function');` or ``` remove_action( 'wooco...
One problem with the way WordPress handles hooks is that to remove a specific hook with an OOP callback, you must have access to the *exact same instance* of the class as when the callback was added. This is generally easy enough to handle in your own plugins/themes. However, it makes it nearly impossible to remove a ...
258,786
<p>I have two fields in wp_posts table that <code>wp_update_post()</code> seems to be unable to change. I'm trying to use the following code:</p> <pre><code>$echo $group_access; $echo $tag_list; $my_post = array( 'ID' =&gt; 12095, 'post_title' =&gt; 'Test Title', 'post_content' =&gt; 'Te...
[ { "answer_id": 258787, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": false, "text": "<p>You are correct; WordPress will not update custom database columns using <code>wp_update_post()</code> or <...
2017/03/03
[ "https://wordpress.stackexchange.com/questions/258786", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38365/" ]
I have two fields in wp\_posts table that `wp_update_post()` seems to be unable to change. I'm trying to use the following code: ``` $echo $group_access; $echo $tag_list; $my_post = array( 'ID' => 12095, 'post_title' => 'Test Title', 'post_content' => 'Test Content', 'group_ac...
You are correct; WordPress will not update custom database columns using `wp_update_post()` or `wp_insert_post()`. Instead of creating custom database columns, consider using post meta and/or taxonomy APIs. If you must altar the `wp_posts` table, you will need to update your custom columns on your own and you may run...
258,806
<p>Google Adsense requires its activation code to be pasted right after the <code>&lt;head&gt;</code> tag of a site.</p> <p>However, I'm using a WordPress child theme.</p> <p>How can I paste my Google Adsense code in a child theme?</p>
[ { "answer_id": 258812, "author": "Irfan Modan", "author_id": 65452, "author_profile": "https://wordpress.stackexchange.com/users/65452", "pm_score": -1, "selected": false, "text": "<p>Use wp_head hook in functions.php</p>\n\n<pre><code>add_action('wp_head','add_adsense');\n</code></pre>\...
2017/03/04
[ "https://wordpress.stackexchange.com/questions/258806", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114691/" ]
Google Adsense requires its activation code to be pasted right after the `<head>` tag of a site. However, I'm using a WordPress child theme. How can I paste my Google Adsense code in a child theme?
You can easily put your Google Adsense code within the `<head>` element of your WordPress site by using either of these methods in your `functions.php` file or by creating a plugin for that purpose: ``` /** * Load my Google Adsense code. * * Here, your Google Adsense Code is stored within in your plugins directory,...
258,834
<p>In WordPress I have a custom post type called 'places' and these posts have one "places tag" each.</p> <p>What PHP code should I insert in the sidebar to print the tag of the current post?</p>
[ { "answer_id": 258812, "author": "Irfan Modan", "author_id": 65452, "author_profile": "https://wordpress.stackexchange.com/users/65452", "pm_score": -1, "selected": false, "text": "<p>Use wp_head hook in functions.php</p>\n\n<pre><code>add_action('wp_head','add_adsense');\n</code></pre>\...
2017/03/04
[ "https://wordpress.stackexchange.com/questions/258834", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114710/" ]
In WordPress I have a custom post type called 'places' and these posts have one "places tag" each. What PHP code should I insert in the sidebar to print the tag of the current post?
You can easily put your Google Adsense code within the `<head>` element of your WordPress site by using either of these methods in your `functions.php` file or by creating a plugin for that purpose: ``` /** * Load my Google Adsense code. * * Here, your Google Adsense Code is stored within in your plugins directory,...
258,835
<p>How we can use function with filter to add ads before and after content, Every ad has its priority. How we can use parameters at function then use it at filter This is the function</p> <pre><code> function mywp_before_after($content) { if(is_page() || is_single()) { $beforecontent = 'This goes before...
[ { "answer_id": 258812, "author": "Irfan Modan", "author_id": 65452, "author_profile": "https://wordpress.stackexchange.com/users/65452", "pm_score": -1, "selected": false, "text": "<p>Use wp_head hook in functions.php</p>\n\n<pre><code>add_action('wp_head','add_adsense');\n</code></pre>\...
2017/03/04
[ "https://wordpress.stackexchange.com/questions/258835", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82877/" ]
How we can use function with filter to add ads before and after content, Every ad has its priority. How we can use parameters at function then use it at filter This is the function ``` function mywp_before_after($content) { if(is_page() || is_single()) { $beforecontent = 'This goes before the content. ...
You can easily put your Google Adsense code within the `<head>` element of your WordPress site by using either of these methods in your `functions.php` file or by creating a plugin for that purpose: ``` /** * Load my Google Adsense code. * * Here, your Google Adsense Code is stored within in your plugins directory,...
258,843
<p>i need to attach an image from a specific post by using post id of custom post type which i created new... how can i..? actually i created a new 5 post type named 'flips'... and meta content areas are website, title back, content back, main title, thumbnail etc.,.</p> <pre><code>&lt;?php $mypost = get_post(28); ec...
[ { "answer_id": 258812, "author": "Irfan Modan", "author_id": 65452, "author_profile": "https://wordpress.stackexchange.com/users/65452", "pm_score": -1, "selected": false, "text": "<p>Use wp_head hook in functions.php</p>\n\n<pre><code>add_action('wp_head','add_adsense');\n</code></pre>\...
2017/03/04
[ "https://wordpress.stackexchange.com/questions/258843", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114712/" ]
i need to attach an image from a specific post by using post id of custom post type which i created new... how can i..? actually i created a new 5 post type named 'flips'... and meta content areas are website, title back, content back, main title, thumbnail etc.,. ``` <?php $mypost = get_post(28); echo apply_filters(...
You can easily put your Google Adsense code within the `<head>` element of your WordPress site by using either of these methods in your `functions.php` file or by creating a plugin for that purpose: ``` /** * Load my Google Adsense code. * * Here, your Google Adsense Code is stored within in your plugins directory,...
258,844
<p>I have a custom post type <code>paper</code> defined in my WordPress plugin that I show along with standard posts in the main query via:</p> <pre><code>function add_custom_post_types_to_query( $query ) { if ( is_home() &amp;&amp; $query-&gt;is_main_query() ) $query-&gt;set( 'post_type', array( 'post', '...
[ { "answer_id": 258848, "author": "David Lee", "author_id": 111965, "author_profile": "https://wordpress.stackexchange.com/users/111965", "pm_score": 0, "selected": false, "text": "<p>create your own function for it:</p>\n\n<pre><code>function get_template_part_custom($content_name) {\n ...
2017/03/04
[ "https://wordpress.stackexchange.com/questions/258844", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114713/" ]
I have a custom post type `paper` defined in my WordPress plugin that I show along with standard posts in the main query via: ``` function add_custom_post_types_to_query( $query ) { if ( is_home() && $query->is_main_query() ) $query->set( 'post_type', array( 'post', 'paper' ) ); // As was pointed out b...
Background ========== Unfortunately [`get_template_part()`](https://developer.wordpress.org/reference/functions/get_template_part/) function doesn't have any suitable filter to achieve what you want. It's possible to use the `get_template_part_{$slug}` action hook to inject template parts, however, without any change ...
258,879
<p>I have a custom post type called "product" and I want to hide an specific widget only if the post type is "product" I was trying with something like this: </p> <pre><code>&lt;?php function hidewidget() { $args = array( 'name' =&gt; 'product' ); $output = 'objects'; $post_types = get_post_types( $args...
[ { "answer_id": 258874, "author": "Paul 'Sparrow Hawk' Biron", "author_id": 113496, "author_profile": "https://wordpress.stackexchange.com/users/113496", "pm_score": 1, "selected": false, "text": "<p>My <em>last resort</em> in such cases is to <strong>temporarily</strong> add a call to th...
2017/03/05
[ "https://wordpress.stackexchange.com/questions/258879", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114736/" ]
I have a custom post type called "product" and I want to hide an specific widget only if the post type is "product" I was trying with something like this: ``` <?php function hidewidget() { $args = array( 'name' => 'product' ); $output = 'objects'; $post_types = get_post_types( $args, $output ); retu...
This is where the rule of avoiding bloat applies best. You should ask yourself why is it that you have so many errors generated with the code you use. In theory you should not fix the errors but wait for the author to fix it as if you fix it yourself you basically forking the plugin/theme. More specific to your questi...
258,937
<p>I have a word press blog and all was fine and one day suddenly all the images in the website have disappeared .. </p> <p>I see the images are there in the wp-content/uploads/ in there specific directory(month &amp; year) but nothing is visible in media library</p> <p>I also noticed all the pages, posts were turne...
[ { "answer_id": 260089, "author": "ricotheque", "author_id": 34238, "author_profile": "https://wordpress.stackexchange.com/users/34238", "pm_score": 0, "selected": false, "text": "<p>Unless you haven't updated your WordPress for a long time, you shouldn't have been able to change your upl...
2017/03/05
[ "https://wordpress.stackexchange.com/questions/258937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/55034/" ]
I have a word press blog and all was fine and one day suddenly all the images in the website have disappeared .. I see the images are there in the wp-content/uploads/ in there specific directory(month & year) but nothing is visible in media library I also noticed all the pages, posts were turned to draft . I republi...
The two problems you describe may very well be related. Attachments (images) [are stored as posts in the database](https://codex.wordpress.org/Using_Image_and_File_Attachments) (so title, caption and so on can be stored in relation to the physical image file). It is this post that you see in the image library. Normall...
258,947
<p>i create a Custom Post and i don't want them has a URL.</p> <p>There is a URL like that = site.com/custom-slug/and-id-or-title <a href="https://i.stack.imgur.com/ldPvd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ldPvd.png" alt="enter image description here"></a></p> <p>and i don't want this,...
[ { "answer_id": 258948, "author": "Paul 'Sparrow Hawk' Biron", "author_id": 113496, "author_profile": "https://wordpress.stackexchange.com/users/113496", "pm_score": 1, "selected": true, "text": "<p>If I correctly understand the question you're asking, you don't want your CPT to be direct...
2017/03/05
[ "https://wordpress.stackexchange.com/questions/258947", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114781/" ]
i create a Custom Post and i don't want them has a URL. There is a URL like that = site.com/custom-slug/and-id-or-title [![enter image description here](https://i.stack.imgur.com/ldPvd.png)](https://i.stack.imgur.com/ldPvd.png) and i don't want this, how i can do that? Thank you already!
If I correctly understand the question you're asking, you don't want your CPT to be directly available on the front-end. If so, then just set `'public' => false` when you register the post\_type. Remember that various other args to [register\_post\_type()](https://developer.wordpress.org/reference/functions/register_p...
258,960
<p>I tired esc_url but it doesn't work.</p> <pre><code>if ( $power_by ) { ?&gt; &lt;div class="sponsor-credits"&gt; &lt;span class="sponsor-credits__label"&gt;Powered by &lt;/span&gt; &lt;span class="sponsor-credits__sponsor"&gt; &lt;?php ...
[ { "answer_id": 258948, "author": "Paul 'Sparrow Hawk' Biron", "author_id": 113496, "author_profile": "https://wordpress.stackexchange.com/users/113496", "pm_score": 1, "selected": true, "text": "<p>If I correctly understand the question you're asking, you don't want your CPT to be direct...
2017/03/05
[ "https://wordpress.stackexchange.com/questions/258960", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114789/" ]
I tired esc\_url but it doesn't work. ``` if ( $power_by ) { ?> <div class="sponsor-credits"> <span class="sponsor-credits__label">Powered by </span> <span class="sponsor-credits__sponsor"> <?php if ( $sponsor_link ) { ...
If I correctly understand the question you're asking, you don't want your CPT to be directly available on the front-end. If so, then just set `'public' => false` when you register the post\_type. Remember that various other args to [register\_post\_type()](https://developer.wordpress.org/reference/functions/register_p...
258,974
<p>I'm using the University Hub theme <a href="http://wenthemes.com/item/wordpress-themes/university-hub/" rel="nofollow noreferrer">http://wenthemes.com/item/wordpress-themes/university-hub/</a> and I searched a lot and didn't found a solution. I want to change the main logo on each page of the site. I managed to chan...
[ { "answer_id": 258975, "author": "Dev", "author_id": 104464, "author_profile": "https://wordpress.stackexchange.com/users/104464", "pm_score": 0, "selected": false, "text": "<p>This is not specific to WordPress however you could try removing the header hook and adding it back with a imag...
2017/03/06
[ "https://wordpress.stackexchange.com/questions/258974", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109894/" ]
I'm using the University Hub theme <http://wenthemes.com/item/wordpress-themes/university-hub/> and I searched a lot and didn't found a solution. I want to change the main logo on each page of the site. I managed to change with CSS the header background color but for the logo it seems I need a custom solution for this ...
I would add a filter to the body class in your functions.php file. This will add a class based on the page/post/cpt slug: **PHP:** ``` /** * * Add Page/Post Body Class Slug * * post-slug-for-post * page-slug-for-page * * */ function yourprefix_page_slug_body_class( $classes ) { global $post; if ( isse...
258,982
<p>I've code to display ACF gallery:</p> <pre><code>&lt;?php $images = get_field('portfolio'); if( $images ): ?&gt; &lt;div class="row"&gt; &lt;?php foreach( $images as $image ): ?&gt; &lt;div class="col-lg-3"&gt; &lt;a href="&lt;?php echo $image['url']; ?&gt;"&gt; ...
[ { "answer_id": 258975, "author": "Dev", "author_id": 104464, "author_profile": "https://wordpress.stackexchange.com/users/104464", "pm_score": 0, "selected": false, "text": "<p>This is not specific to WordPress however you could try removing the header hook and adding it back with a imag...
2017/03/06
[ "https://wordpress.stackexchange.com/questions/258982", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48584/" ]
I've code to display ACF gallery: ``` <?php $images = get_field('portfolio'); if( $images ): ?> <div class="row"> <?php foreach( $images as $image ): ?> <div class="col-lg-3"> <a href="<?php echo $image['url']; ?>"> <img src="<?php echo $image['sizes']['t...
I would add a filter to the body class in your functions.php file. This will add a class based on the page/post/cpt slug: **PHP:** ``` /** * * Add Page/Post Body Class Slug * * post-slug-for-post * page-slug-for-page * * */ function yourprefix_page_slug_body_class( $classes ) { global $post; if ( isse...
258,995
<p>I am a newbie who recently start working on XAMPP and I am unable to access wp-admin on XAMPP server localhost. While installing WordPress, it asked me for user name and password too but when I am trying to access wp-admin with username and password, it says "INVALID USER NAME". As far as I know, I am putting the c...
[ { "answer_id": 258975, "author": "Dev", "author_id": 104464, "author_profile": "https://wordpress.stackexchange.com/users/104464", "pm_score": 0, "selected": false, "text": "<p>This is not specific to WordPress however you could try removing the header hook and adding it back with a imag...
2017/03/06
[ "https://wordpress.stackexchange.com/questions/258995", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114807/" ]
I am a newbie who recently start working on XAMPP and I am unable to access wp-admin on XAMPP server localhost. While installing WordPress, it asked me for user name and password too but when I am trying to access wp-admin with username and password, it says "INVALID USER NAME". As far as I know, I am putting the corre...
I would add a filter to the body class in your functions.php file. This will add a class based on the page/post/cpt slug: **PHP:** ``` /** * * Add Page/Post Body Class Slug * * post-slug-for-post * page-slug-for-page * * */ function yourprefix_page_slug_body_class( $classes ) { global $post; if ( isse...
258,999
<p>I have a url structure like this where taobao is a page:</p> <pre><code>http://website.com/taobao/?item=123123 </code></pre> <p>I need to change it to like this </p> <pre><code>http://website.com/taobao/item/123123 </code></pre> <p>I have tried this but it doesn't work </p> <pre><code> add_rewrite_rule( 'produc...
[ { "answer_id": 258975, "author": "Dev", "author_id": 104464, "author_profile": "https://wordpress.stackexchange.com/users/104464", "pm_score": 0, "selected": false, "text": "<p>This is not specific to WordPress however you could try removing the header hook and adding it back with a imag...
2017/03/06
[ "https://wordpress.stackexchange.com/questions/258999", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91745/" ]
I have a url structure like this where taobao is a page: ``` http://website.com/taobao/?item=123123 ``` I need to change it to like this ``` http://website.com/taobao/item/123123 ``` I have tried this but it doesn't work ``` add_rewrite_rule( 'product/([^/]+)', 'index.php?product=$matches[1]', 'top' ); ```
I would add a filter to the body class in your functions.php file. This will add a class based on the page/post/cpt slug: **PHP:** ``` /** * * Add Page/Post Body Class Slug * * post-slug-for-post * page-slug-for-page * * */ function yourprefix_page_slug_body_class( $classes ) { global $post; if ( isse...
259,007
<p>How do I change the height of the header image (specified in the Header Media section) in the Twenty Seventeen Theme?</p> <p>Specifically I want to change it on the home page because here it fills up nearly the entire page. I want it to be much shorter. The way it appears on other pages such as the built-in About ...
[ { "answer_id": 259015, "author": "lalitpendhare", "author_id": 114472, "author_profile": "https://wordpress.stackexchange.com/users/114472", "pm_score": 0, "selected": false, "text": "<p>You can be changed it by cropping the image. in WordPress, there is an option as customizer. You need...
2017/03/06
[ "https://wordpress.stackexchange.com/questions/259007", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52057/" ]
How do I change the height of the header image (specified in the Header Media section) in the Twenty Seventeen Theme? Specifically I want to change it on the home page because here it fills up nearly the entire page. I want it to be much shorter. The way it appears on other pages such as the built-in About page has a ...
I found (part) of the css code that controls the height in `wp-content/themes/twentyseventeen/style.css`. There is code that applies when the admin bar *is not* visible (typical anonymous user) currently at line 3629 ``` .twentyseventeen-front-page.has-header-image .custom-header-media, .twentyseventeen-front-page.h...
259,039
<p>I am using wordpress as a submodule and capristrano to deploy.</p> <p>The deployment seems to work correctly and i am able to log in to wp-admin, but when i look at my themes </p> <pre><code>ERROR: The theme directory "sage-master" does not exist. </code></pre> <p>The submodule setup adds the wp-content files to ...
[ { "answer_id": 259088, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>Look for a folder called 'sage-master' in the themes folder of wp-content. If not found, a similarly-n...
2017/03/06
[ "https://wordpress.stackexchange.com/questions/259039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114835/" ]
I am using wordpress as a submodule and capristrano to deploy. The deployment seems to work correctly and i am able to log in to wp-admin, but when i look at my themes ``` ERROR: The theme directory "sage-master" does not exist. ``` The submodule setup adds the wp-content files to site\_url.com/content ie site\_ur...
I'm giving possible cases from the top of my head: ***Case 1:*** May be it's related to [`realpath()`](http://php.net/manual/en/function.realpath.php) function. `realpath()` acts differently in different OS. Also, it returns `false` if the web server user doesn't have executable permission on the corresponding directo...
259,041
<p>I'm registering a custom post type named Datasheet. When registering it, I register the callback for meta boxes</p> <pre><code>'register_meta_box_cb' =&gt; [ $this, "add_metaboxes" ] </code></pre> <p>This is my callback</p> <pre><code>function add_metaboxes ( $post ) { wp_nonce_field ( plugin_basename(__FIL...
[ { "answer_id": 259044, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>You should not have a nonce in your metabox, and obviously not check for it in your save handler. </p>\n\...
2017/03/06
[ "https://wordpress.stackexchange.com/questions/259041", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94289/" ]
I'm registering a custom post type named Datasheet. When registering it, I register the callback for meta boxes ``` 'register_meta_box_cb' => [ $this, "add_metaboxes" ] ``` This is my callback ``` function add_metaboxes ( $post ) { wp_nonce_field ( plugin_basename(__FILE__), 'datasheet_meta_nonce'); add_me...
When you choose "Your CPT > Add New", WP calls [get\_default\_post\_to\_edit()](https://developer.wordpress.org/reference/functions/get_default_post_to_edit/), which actually creates an "empty" post (with `'post_status' => 'auto-draft'`) and then calls [wp\_insert\_post()](https://developer.wordpress.org/reference/func...
259,083
<p>I am trying to use the customiser to set the background image of each 'post-block' to be that of any image I choose to upload. Here is my code so far.</p> <pre><code>function jhwdblog_customize_register( $wp_customize ) { $wp_customize-&gt;add_section( 'post_box_image_section' , array( 'title' ...
[ { "answer_id": 259050, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 1, "selected": false, "text": "<p>Why have WP_Query() when you can just use WPDB?</p>\n\n<p>The idea is that these functions make it easier a...
2017/03/06
[ "https://wordpress.stackexchange.com/questions/259083", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105658/" ]
I am trying to use the customiser to set the background image of each 'post-block' to be that of any image I choose to upload. Here is my code so far. ``` function jhwdblog_customize_register( $wp_customize ) { $wp_customize->add_section( 'post_box_image_section' , array( 'title' => __( 'Post Box ...
1. [`wp_update_post()`](https://core.trac.wordpress.org/browser/tags/4.7/src/wp-includes/post.php#L3534) calls some hooks that `$wpdb` doesn't on it's own. You'll have to do it on your own to make it compatible with other plugins. 2. `wp_update_post()` calls some functions related to database entry sanitation, thumbnai...
259,110
<p>Does anyone know how to programatically change link from:</p> <pre><code>&lt;a href="some_url"&gt;click&lt;/a&gt; </code></pre> <p>to:</p> <pre><code>&lt;a onclick="window.open('some_url','_blank', 'location=no')"&gt;click&lt;/a&gt; </code></pre> <p>so that all links created in the wordpress visual editor be ope...
[ { "answer_id": 259114, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>There are several plugins that will do that automatically. One is \"Open External Links in New Window\...
2017/03/07
[ "https://wordpress.stackexchange.com/questions/259110", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114875/" ]
Does anyone know how to programatically change link from: ``` <a href="some_url">click</a> ``` to: ``` <a onclick="window.open('some_url','_blank', 'location=no')">click</a> ``` so that all links created in the wordpress visual editor be opened via inappbrowser in a cordova app. this is the closest that i can ge...
Parsing HTML with regular expressions is not ideal. A better alternative is to use `DOMDocument` and `DOMXpath`; This code uses `DOMDocument` and `DOMXpath` to parse and modify the HTML without relying on regular expressions. Each link in the content will have the `onclick` attribute added along with the appropriate `...
259,119
<p>My goal is to add to WooCommerce <code>/my-account</code> page a select input type. The options of the select field will be controlled by ACF repeater in ACF options page, and will be inserted to <code>wp_usermeta</code> table.</p> <p>I palce d this code in functions.php file.</p> <pre><code> while ( have_rows(...
[ { "answer_id": 259122, "author": "Aniruddha Gawade", "author_id": 101818, "author_profile": "https://wordpress.stackexchange.com/users/101818", "pm_score": 0, "selected": false, "text": "<p>When You're not in <code>The Loop</code> you have to pass page ID as parameter to ACF functions.</...
2017/03/07
[ "https://wordpress.stackexchange.com/questions/259119", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88244/" ]
My goal is to add to WooCommerce `/my-account` page a select input type. The options of the select field will be controlled by ACF repeater in ACF options page, and will be inserted to `wp_usermeta` table. I palce d this code in functions.php file. ``` while ( have_rows('group_email') ) : the_row(); ?> ...
The functions.php file doesn't know where you want that code to be shown on the front end. You need to put the code into a template page (ie the woocommerce account page) or attach it to that page with a woocommerce hook to the template. You'll need to add it into a function to properly work if you decide it's better...
259,128
<p>Didn't thought I would have to ask this question. But yes, it's true. It seems you can't have a separate child menu in Wordpress?</p> <p>I'm absolutely not a beginner on Wordpress. Have worked and developed in it for years.</p> <p>However, it might be possible to do a big walkaround to get the separate child/sub m...
[ { "answer_id": 259140, "author": "Svartbaard", "author_id": 112928, "author_profile": "https://wordpress.stackexchange.com/users/112928", "pm_score": 1, "selected": false, "text": "<p>What exactly do you mean by separate child menu? Could you provide a use case?</p>\n\n<p>The way I under...
2017/03/07
[ "https://wordpress.stackexchange.com/questions/259128", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3216/" ]
Didn't thought I would have to ask this question. But yes, it's true. It seems you can't have a separate child menu in Wordpress? I'm absolutely not a beginner on Wordpress. Have worked and developed in it for years. However, it might be possible to do a big walkaround to get the separate child/sub menu. But what I w...
Found [the solution](https://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-based-on-parent-or-sibling/). Put this in your **function.php** file: ``` // add hook add_filter( 'wp_nav_menu_objects', 'my_wp_nav_menu_objects_sub_menu', 10, 2 ); // filter_hook function to react on sub_menu flag function ...
259,176
<p>I'm encountering a 301 problem from my pre-production site which is automatically redirected to my production site. I know the problem comes from WP because I already launched a curl in order to see responses either :</p> <p>1) targeting the <strong>WP pre-production-site</strong> :</p> <pre><code>&gt; GET / HTTP/...
[ { "answer_id": 259266, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 1, "selected": false, "text": "<p>Did you check the 'options' table in your WP databasse for the two instances of the domain name (somet...
2017/03/07
[ "https://wordpress.stackexchange.com/questions/259176", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114899/" ]
I'm encountering a 301 problem from my pre-production site which is automatically redirected to my production site. I know the problem comes from WP because I already launched a curl in order to see responses either : 1) targeting the **WP pre-production-site** : ``` > GET / HTTP/1.1 > Host: www.pre-production-site.c...
Did you check the 'options' table in your WP databasse for the two instances of the domain name (something like '<http://www.example.com> ' ). Not clear if your pre-production site is hosted on a local machine, or networked server. Might be some firewall redirection rules causing issues.
259,195
<p>I have some very basic data that I am posting to a proprietary lead capturing system. Whenever I submit my form data to their system the body of the request is an error 500 page.</p> <p>I am trying to debug the problem with their developer, it clearly doesn't like something in my query string, and he would like to ...
[ { "answer_id": 259201, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 0, "selected": false, "text": "<p>You can have a look into the classes inside <a href=\"https://core.svn.wordpress.org/tags/4.7.3/wp-includes/...
2017/03/07
[ "https://wordpress.stackexchange.com/questions/259195", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14064/" ]
I have some very basic data that I am posting to a proprietary lead capturing system. Whenever I submit my form data to their system the body of the request is an error 500 page. I am trying to debug the problem with their developer, it clearly doesn't like something in my query string, and he would like to be able to...
While the other answers are pretty good in providing an answer to your question (how to get the generated url), i will answer what i guess you really want to know (how do i get it to call thirdparty.com?foo=bar with wp\_remote\_get) The Answer is: the $args array you use to transmit the url parameters won't work like ...
259,250
<p>The code below is meant to simply loop through posts, give the opportunity to add html formatting to them, then return them to the shortcode position. I have conditional logic which defines formatting based on the passed in "category"(term). I need to output it twice on the same page, but I only see code that I've a...
[ { "answer_id": 259201, "author": "kraftner", "author_id": 47733, "author_profile": "https://wordpress.stackexchange.com/users/47733", "pm_score": 0, "selected": false, "text": "<p>You can have a look into the classes inside <a href=\"https://core.svn.wordpress.org/tags/4.7.3/wp-includes/...
2017/03/07
[ "https://wordpress.stackexchange.com/questions/259250", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64943/" ]
The code below is meant to simply loop through posts, give the opportunity to add html formatting to them, then return them to the shortcode position. I have conditional logic which defines formatting based on the passed in "category"(term). I need to output it twice on the same page, but I only see code that I've adde...
While the other answers are pretty good in providing an answer to your question (how to get the generated url), i will answer what i guess you really want to know (how do i get it to call thirdparty.com?foo=bar with wp\_remote\_get) The Answer is: the $args array you use to transmit the url parameters won't work like ...
259,255
<p>I am using Advanced Custom Fields and trying to build a navigation menu where the current item has an extra class on it to let them know where they are.</p> <p><strong>The entire structure in question. It's using ACF repeater fields:</strong></p> <pre><code>&lt;?php if(get_field('main_nav', 53)): ?&gt; &lt;?php wh...
[ { "answer_id": 259257, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p><code>the_permalink</code> doesn't do what you think it does.</p>\n\n<p>For example, this:</p>\n\n<pre><code...
2017/03/07
[ "https://wordpress.stackexchange.com/questions/259255", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114953/" ]
I am using Advanced Custom Fields and trying to build a navigation menu where the current item has an extra class on it to let them know where they are. **The entire structure in question. It's using ACF repeater fields:** ``` <?php if(get_field('main_nav', 53)): ?> <?php while(has_sub_field('main_nav', 53)): ?> <li>...
Both `the_permalink()` and `the_sub_field()` are functions that do more than output a string or URL. Try using`get_permalink()` and `get_sub_field` instead: ``` $link1 = get_permalink(); $link2 = get_sub_field('link_url'); ```
259,334
<p>Out setup is multiple Front Ends (replicated) and 2 Backend MYSQL servers (Master-Master replication).</p> <p>We're looking to achieve HA automatic failover for wordpress. We've got the front ends covered through replication and a load balancer. </p> <p>Any ideas on how to achieve <strong>AUTOMATIC</strong> MySQL ...
[ { "answer_id": 259257, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p><code>the_permalink</code> doesn't do what you think it does.</p>\n\n<p>For example, this:</p>\n\n<pre><code...
2017/03/08
[ "https://wordpress.stackexchange.com/questions/259334", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/78065/" ]
Out setup is multiple Front Ends (replicated) and 2 Backend MYSQL servers (Master-Master replication). We're looking to achieve HA automatic failover for wordpress. We've got the front ends covered through replication and a load balancer. Any ideas on how to achieve **AUTOMATIC** MySQL failover? Thanks in advance.
Both `the_permalink()` and `the_sub_field()` are functions that do more than output a string or URL. Try using`get_permalink()` and `get_sub_field` instead: ``` $link1 = get_permalink(); $link2 = get_sub_field('link_url'); ```
259,352
<p>I am trying to create a custom meta box that lets you add rows dynamically. Following code snippet works fine and and saves data in my edit page section. However, I can't get it to display the data on the actual page:</p> <pre><code> add_action( 'add_meta_boxes', 'dynamic_add_custom_box' ); /* Do something ...
[ { "answer_id": 259356, "author": "Abdul Awal Uzzal", "author_id": 31449, "author_profile": "https://wordpress.stackexchange.com/users/31449", "pm_score": 2, "selected": true, "text": "<p>Try changing <code>$meta['title']</code> to <code>$meta['title'][0]</code> &amp; the same thing for <...
2017/03/08
[ "https://wordpress.stackexchange.com/questions/259352", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115021/" ]
I am trying to create a custom meta box that lets you add rows dynamically. Following code snippet works fine and and saves data in my edit page section. However, I can't get it to display the data on the actual page: ``` add_action( 'add_meta_boxes', 'dynamic_add_custom_box' ); /* Do something with the data ...
Try changing `$meta['title']` to `$meta['title'][0]` & the same thing for `$meta['track']` . change it to `$meta['track'][0]` **UPDATE:** I looked at the code more deeply and you basically need a foreach loop. Here's the final code should look like: ``` <?php $args = array( 'post_type' => 'page' ); $repeat_loo...
259,396
<p>I'm building my child theme, but including materialize css that I want to use, breaks the entire site when enqueued in <strong>functions.php</strong>. How do I change that?</p> <pre><code>function bla_enqueue_child_theme_styles() { wp_enqueue_style('cookie-font', 'http://fonts.googleapis.com/css?family=Cookie'...
[ { "answer_id": 259406, "author": "tillinberlin", "author_id": 26059, "author_profile": "https://wordpress.stackexchange.com/users/26059", "pm_score": 1, "selected": false, "text": "<p>You could first <strong>dequeue</strong> the <em>parent stylesheet</em>, then <strong>enqueue</strong> t...
2017/03/08
[ "https://wordpress.stackexchange.com/questions/259396", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99302/" ]
I'm building my child theme, but including materialize css that I want to use, breaks the entire site when enqueued in **functions.php**. How do I change that? ``` function bla_enqueue_child_theme_styles() { wp_enqueue_style('cookie-font', 'http://fonts.googleapis.com/css?family=Cookie'); //wp_enqueue_style('...
> > How do I load it before the parent theme? > > > I think you are doing it right. If the parent theme is attaching the function responsible for enqueueing its styles to the `wp_enqueue_scripts` hook, then your `bla_enqueue_child_theme_styles()` function must be being executed first (because you passed `-20` as p...
259,410
<p>Wordpress renders a meta description tag with the content of the blog post as the value for the description.</p> <p>I already generated in the <code>header.php</code> what I want the description to be, no matter what. However, the old one is still in there. I checked <code>single-post.php</code> and <code>header.ph...
[ { "answer_id": 259467, "author": "hcheung", "author_id": 111577, "author_profile": "https://wordpress.stackexchange.com/users/111577", "pm_score": 0, "selected": false, "text": "<p>If you want to remote <code>&lt;meta name=\"description\" content=\"\" /&gt;</code> in html head, Add </p>\...
2017/03/08
[ "https://wordpress.stackexchange.com/questions/259410", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114799/" ]
Wordpress renders a meta description tag with the content of the blog post as the value for the description. I already generated in the `header.php` what I want the description to be, no matter what. However, the old one is still in there. I checked `single-post.php` and `header.php` and there is nothing rendering the...
You should be able to remove the existing description tag with the following code: ``` remove_action( 'wp_head', '_wp_render_title_tag', 1 ); ``` Put the above snippet inside the same function you are using to conditionally add a new tag so there is always only a single description tag at a time.
259,416
<p>I have a custom post template on which I want to show a list of other children of this post's parent. I already have the parent post ID in a variable ($parent_artist_id), which is being used elsewhere on the page. Here is my code:</p> <pre><code> $pastshowargs = array( 'post_parent' =&gt; $parent_artist_id...
[ { "answer_id": 259467, "author": "hcheung", "author_id": 111577, "author_profile": "https://wordpress.stackexchange.com/users/111577", "pm_score": 0, "selected": false, "text": "<p>If you want to remote <code>&lt;meta name=\"description\" content=\"\" /&gt;</code> in html head, Add </p>\...
2017/03/08
[ "https://wordpress.stackexchange.com/questions/259416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31013/" ]
I have a custom post template on which I want to show a list of other children of this post's parent. I already have the parent post ID in a variable ($parent\_artist\_id), which is being used elsewhere on the page. Here is my code: ``` $pastshowargs = array( 'post_parent' => $parent_artist_id, 'post_t...
You should be able to remove the existing description tag with the following code: ``` remove_action( 'wp_head', '_wp_render_title_tag', 1 ); ``` Put the above snippet inside the same function you are using to conditionally add a new tag so there is always only a single description tag at a time.
259,420
<p>I am doing a post in wordpress, but I want to put a video as part of the post. I mean, I have a paragraph but after the paragraph I want to put a video. I did put it as media, but it just shows a link and if I clic on the link it downloads the file, and I just want to play the video, not to download it. What can I d...
[ { "answer_id": 259467, "author": "hcheung", "author_id": 111577, "author_profile": "https://wordpress.stackexchange.com/users/111577", "pm_score": 0, "selected": false, "text": "<p>If you want to remote <code>&lt;meta name=\"description\" content=\"\" /&gt;</code> in html head, Add </p>\...
2017/03/08
[ "https://wordpress.stackexchange.com/questions/259420", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114684/" ]
I am doing a post in wordpress, but I want to put a video as part of the post. I mean, I have a paragraph but after the paragraph I want to put a video. I did put it as media, but it just shows a link and if I clic on the link it downloads the file, and I just want to play the video, not to download it. What can I do? ...
You should be able to remove the existing description tag with the following code: ``` remove_action( 'wp_head', '_wp_render_title_tag', 1 ); ``` Put the above snippet inside the same function you are using to conditionally add a new tag so there is always only a single description tag at a time.
259,441
<p>I wanted to add a search form inside a div using the code bellow:</p> <p><code>printf( '&lt;div class="entry"&gt;&lt;p&gt;%s&lt;/p&gt;%s&lt;/div&gt;', apply_filters( 'genesis_noposts_text', __( 'Try again below.', 'genesis' ) ), get_search_form() );</code></p> <p>But every time I add the <code>get_search_form()</c...
[ { "answer_id": 259443, "author": "Christina", "author_id": 64742, "author_profile": "https://wordpress.stackexchange.com/users/64742", "pm_score": 3, "selected": true, "text": "<p>The <code>get_search_form()</code> echos so it will always show up before returns. Use:</p>\n\n<pre><code>ge...
2017/03/09
[ "https://wordpress.stackexchange.com/questions/259441", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115018/" ]
I wanted to add a search form inside a div using the code bellow: `printf( '<div class="entry"><p>%s</p>%s</div>', apply_filters( 'genesis_noposts_text', __( 'Try again below.', 'genesis' ) ), get_search_form() );` But every time I add the `get_search_form()` it's generated before the div, like the following: ``` <f...
The `get_search_form()` echos so it will always show up before returns. Use: ``` get_search_form( false ) ```
259,447
<p>I wanted to know if there were any ways to easily hide a selected user's user page. I've yet to find any code that does so. I've only found code to remove all user pages.</p> <p>Thanks</p>
[ { "answer_id": 259448, "author": "Faysal Mahamud", "author_id": 83752, "author_profile": "https://wordpress.stackexchange.com/users/83752", "pm_score": 0, "selected": false, "text": "<p>If you want to hide the user in user list page. The following working for you.</p>\n\n<p>//yousiteurl/...
2017/03/09
[ "https://wordpress.stackexchange.com/questions/259447", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96587/" ]
I wanted to know if there were any ways to easily hide a selected user's user page. I've yet to find any code that does so. I've only found code to remove all user pages. Thanks
I'm assuming you want to hide the author page on the site itself (and not in `wp-admin`). To do that, just create a new template file called `author-{$id}.php`, where `{$id}` is replaced by the ID of the author you want to hide. So if the author ID is `6`, the template file should be called `author-6.php`. Inside the...
259,485
<p>My head is clearly not working here. The logic is simple but I can't seem to get it right. </p> <p>I have a tv schedule post type and I want to display: </p> <p><code>2016-12-01 2017-04-01 2017-05-17</code></p> <p>Instead of: <code>2016-12-01 2017-03-01 2017-03-01 2017-03-01 2017-03-01 2017-03-01</code></p> <p>...
[ { "answer_id": 259525, "author": "Industrial Themes", "author_id": 274, "author_profile": "https://wordpress.stackexchange.com/users/274", "pm_score": 1, "selected": false, "text": "<p>Just set a flag to check for a new value, and only display the date if the new value does not match the...
2017/03/09
[ "https://wordpress.stackexchange.com/questions/259485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
My head is clearly not working here. The logic is simple but I can't seem to get it right. I have a tv schedule post type and I want to display: `2016-12-01 2017-04-01 2017-05-17` Instead of: `2016-12-01 2017-03-01 2017-03-01 2017-03-01 2017-03-01 2017-03-01` At the moment I am stuck with repeating times. I want...
I finally got it right... I knew my big head was not working: ``` <?php $args = array( 'post_type' => 'tv-schedule', 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'ASC', 'post_status' => array('publish', 'future'), ); $posts_array = query_posts($args); $lastdate = ""; foreac...
259,493
<p>How to send user data in json format to another server when user register on wordpress site in PHP. I have a server url is like (<a href="http://1.2.3.4:49005/SingleMethodName=DomainManagementStripeService___DomainRegistration" rel="nofollow noreferrer">http://1.2.3.4:49005/SingleMethodName=DomainManagementStripeSer...
[ { "answer_id": 259525, "author": "Industrial Themes", "author_id": 274, "author_profile": "https://wordpress.stackexchange.com/users/274", "pm_score": 1, "selected": false, "text": "<p>Just set a flag to check for a new value, and only display the date if the new value does not match the...
2017/03/09
[ "https://wordpress.stackexchange.com/questions/259493", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/108076/" ]
How to send user data in json format to another server when user register on wordpress site in PHP. I have a server url is like (<http://1.2.3.4:49005/SingleMethodName=DomainManagementStripeService___DomainRegistration>) when user register on wordpress site i want to send their name, email, custom fields data to my se...
I finally got it right... I knew my big head was not working: ``` <?php $args = array( 'post_type' => 'tv-schedule', 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'ASC', 'post_status' => array('publish', 'future'), ); $posts_array = query_posts($args); $lastdate = ""; foreac...
259,499
<p>There is the following hierarchical taxonomy structure of a specific post:</p> <ul> <li>Term A <ul> <li>SubTerm A.1</li> <li>SubTerm A.2 <ul> <li>SubTerm A.2.1</li> </ul></li> </ul></li> <li>Term B <ul> <li>SubTerm B.1 <ul> <li>SubTerm B.1.1</li> <li>SubTerm B.1.2</li> </ul></li> </ul></li> </ul> <p>How to...
[ { "answer_id": 259502, "author": "Ben Casey", "author_id": 114997, "author_profile": "https://wordpress.stackexchange.com/users/114997", "pm_score": 1, "selected": false, "text": "<p>I love a good challenge!</p>\n\n<p>The function here:</p>\n\n<pre><code>function get_post_categories_sort...
2017/03/09
[ "https://wordpress.stackexchange.com/questions/259499", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51307/" ]
There is the following hierarchical taxonomy structure of a specific post: * Term A + SubTerm A.1 + SubTerm A.2 - SubTerm A.2.1 * Term B + SubTerm B.1 - SubTerm B.1.1 - SubTerm B.1.2 How to display 1. all parent terms (result: A, B) 2. all second level terms (result: A.1, A.2, B.1) 3. all third level terms ...
I love a good challenge! The function here: ``` function get_post_categories_sorted ( $post_id ){ $terms = wp_get_post_terms( $post_id, 'category' ); $sorted_terms = []; foreach( $terms as $term ){ $depth = count( get_ancestors( $term->term_id, 'category' ) ); if( ! array_key_exists( ...
259,501
<p>On a site where I filter custom taxonomy terms with FacetWP I'm trying to have the taxonomy term links go back to the homepage with the filters, instead of linking to the taxonomy term archives.</p> <p>I am not sure how to go about this, <code>term_link()</code> filter or rewrite rule. Of the filter there is little...
[ { "answer_id": 259514, "author": "Laxmana", "author_id": 40948, "author_profile": "https://wordpress.stackexchange.com/users/40948", "pm_score": 2, "selected": true, "text": "<p>I know I am not answering exactly your question but in my opinion it is best to do it manually without messing...
2017/03/09
[ "https://wordpress.stackexchange.com/questions/259501", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
On a site where I filter custom taxonomy terms with FacetWP I'm trying to have the taxonomy term links go back to the homepage with the filters, instead of linking to the taxonomy term archives. I am not sure how to go about this, `term_link()` filter or rewrite rule. Of the filter there is little info available and m...
I know I am not answering exactly your question but in my opinion it is best to do it manually without messing with rewrite rules and filters. That way you keep also the default URL structure for terms templates, other plugins etc. ``` $terms = get_the_terms( $post->ID, 'industry'); if($terms && !is_wp_error($terms))...
259,544
<p>I am creating my own theme and was wondering if there is a way to remove <code>get_template_part()</code> when you're on a specific page? For example:</p> <pre><code>&lt;?php if ( is_page('blog') ) { [Remove]get_template_part('the', 'blog'); } ?&gt; </code></pre>
[ { "answer_id": 259548, "author": "nibnut", "author_id": 111316, "author_profile": "https://wordpress.stackexchange.com/users/111316", "pm_score": 0, "selected": false, "text": "<p>So I can think of a couple of ways at least:</p>\n\n<ol>\n<li>You could make a <a href=\"https://developer.w...
2017/03/09
[ "https://wordpress.stackexchange.com/questions/259544", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106262/" ]
I am creating my own theme and was wondering if there is a way to remove `get_template_part()` when you're on a specific page? For example: ``` <?php if ( is_page('blog') ) { [Remove]get_template_part('the', 'blog'); } ?> ```
you could do it the opposite way: ``` <?php if ( !is_page('blog') ) { get_template_part('the', 'blog'); } ?> ``` this would make it show up on all pages but the blog.
259,557
<p>I have tried out a few things to remove the <code>&lt;br&gt;</code> being created in between shortcodes, I found one in another thread, it looked promising, but it didn't work out:</p> <pre><code>function the_content_filter($content) { $block = join("|",array("category_product_list", "category_products")); ...
[ { "answer_id": 259620, "author": "LWS-Mo", "author_id": 88895, "author_profile": "https://wordpress.stackexchange.com/users/88895", "pm_score": 1, "selected": false, "text": "<p>I created a simple shortcode and added it two times to a page like so:</p>\n\n<pre><code>[my-shortcode]somethi...
2017/03/09
[ "https://wordpress.stackexchange.com/questions/259557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96257/" ]
I have tried out a few things to remove the `<br>` being created in between shortcodes, I found one in another thread, it looked promising, but it didn't work out: ``` function the_content_filter($content) { $block = join("|",array("category_product_list", "category_products")); $rep = preg_replace("/(<p>)?\[(...
I created a simple shortcode and added it two times to a page like so: ``` [my-shortcode]something[/my-shortcode] [my-shortcode]else[/my-shortcode] ``` As you can see, I added a line break (`<br />`) after the first shortcode. So in the frontend it is also shown like this: ``` something else ``` And in the HTML: ...
259,567
<p>I'm trying to figure out how to retrieve a user's roles from the API, but I haven't been able to sort it. Is this information not accessible by default?</p> <p>Can anyone point me in the right direction?</p>
[ { "answer_id": 259816, "author": "Shane Piscine", "author_id": 115129, "author_profile": "https://wordpress.stackexchange.com/users/115129", "pm_score": 1, "selected": false, "text": "<p>It seems that the short answer is you can't get there from here. While it's possible create users wit...
2017/03/10
[ "https://wordpress.stackexchange.com/questions/259567", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115129/" ]
I'm trying to figure out how to retrieve a user's roles from the API, but I haven't been able to sort it. Is this information not accessible by default? Can anyone point me in the right direction?
This is totally possible by registering your own rest field into the response. Here's some documentation on modifying response data. <https://developer.wordpress.org/rest-api/extending-the-rest-api/modifying-responses/> Here's how to add roles to the endpoint: ``` function get_user_roles($object, $field_name, $requ...
259,586
<p>I'm extending Wordpress REST API with a custom plugin, and I'm in the need of adding a new field to the user response.</p> <p>The problem is that this field has to appear only in base of the user role.</p> <p>For example I want a field <code>custom_field</code> appear in the response only if the user is <code>admi...
[ { "answer_id": 259592, "author": "Ben Casey", "author_id": 114997, "author_profile": "https://wordpress.stackexchange.com/users/114997", "pm_score": 0, "selected": false, "text": "<p>You can use the filter <code>rest_prepare_user</code></p>\n\n<p>Something like this should do the trick I...
2017/03/10
[ "https://wordpress.stackexchange.com/questions/259586", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109855/" ]
I'm extending Wordpress REST API with a custom plugin, and I'm in the need of adding a new field to the user response. The problem is that this field has to appear only in base of the user role. For example I want a field `custom_field` appear in the response only if the user is `administrator` and not `contributor`....
I found a better workaround using the same filter suggested by @ben-casey in [his answer](https://wordpress.stackexchange.com/a/259592/109855). Firstly I registered throuhg `register_rest_field` all the custom fields of all the user types I have in the database. Then in `rest_prepare_user`, insted adding the wanted f...
259,600
<p>I am building a wordpress theme, I reach the step of finalization.</p> <p>Right now, I am struggling to fix an error raised by Theme Check, :</p> <blockquote> <p>file_get_contents was found in the file functions.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.<...
[ { "answer_id": 259625, "author": "Nathan Johnson", "author_id": 106269, "author_profile": "https://wordpress.stackexchange.com/users/106269", "pm_score": 0, "selected": false, "text": "<p>You shouldn't be echoing your CSS styles in the <code>&lt;head&gt;</code>. You should be using <a hr...
2017/03/10
[ "https://wordpress.stackexchange.com/questions/259600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104277/" ]
I am building a wordpress theme, I reach the step of finalization. Right now, I am struggling to fix an error raised by Theme Check, : > > file\_get\_contents was found in the file functions.php File operations > should use the WP\_Filesystem methods instead of direct PHP filesystem > calls. > > > Here the cod...
To Add External Atylesheet: =========================== Generally speaking, you should use the [`wp_enqueue_style()`](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) function to add external stylesheet to your theme. ``` function wpse259600_add_style() { wp_enqueue_style( 'theme_critical', ...
259,624
<p>I currently have:</p> <blockquote> <p>mywebsite.com/custom-post-type-1/postname</p> <p>mywebsite.com/custom-post-type-2/postname</p> </blockquote> <p>I want to achieve:</p> <blockquote> <p>mywebsite.com/my-base-slug/custom-post-type-1/postname</p> <p>mywebsite.com/my-base-slug/custom-post-type-2/pos...
[ { "answer_id": 259629, "author": "geraldo", "author_id": 38096, "author_profile": "https://wordpress.stackexchange.com/users/38096", "pm_score": 0, "selected": false, "text": "<p>If you are fine with using a plugin, just have a look at <a href=\"https://wordpress.org/plugins/custom-post-...
2017/03/10
[ "https://wordpress.stackexchange.com/questions/259624", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115167/" ]
I currently have: > > mywebsite.com/custom-post-type-1/postname > > > mywebsite.com/custom-post-type-2/postname > > > I want to achieve: > > mywebsite.com/my-base-slug/custom-post-type-1/postname > > > mywebsite.com/my-base-slug/custom-post-type-2/postname > > > I do not want `"my-base-slug"` to appear ...
You can achieve this with the `slug` argument when you [register your post type](https://codex.wordpress.org/Function_Reference/register_post_type). ``` $args = array( 'rewrite' => array( 'slug' => 'my-base-slug/custom-post-type-1' ), // your other args... ); register_post_type( 'mycpt', $args ); ```
259,639
<p>I mention "full website" because I don't need the number of attachments on one post (as answered in many questions). I basically need a function that returns the number of uploaded images (attached and unattached) on the website, excluding non-image files.</p> <p>I've done some research, but there isn’t any direct ...
[ { "answer_id": 259642, "author": "Paul 'Sparrow Hawk' Biron", "author_id": 113496, "author_profile": "https://wordpress.stackexchange.com/users/113496", "pm_score": 2, "selected": false, "text": "<p>The simplest way I know is:</p>\n\n<pre><code>global $wpdb ;\n\n$sql = \"SELECT COUNT(*) ...
2017/03/10
[ "https://wordpress.stackexchange.com/questions/259639", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115176/" ]
I mention "full website" because I don't need the number of attachments on one post (as answered in many questions). I basically need a function that returns the number of uploaded images (attached and unattached) on the website, excluding non-image files. I've done some research, but there isn’t any direct function t...
There's a handy [built-in function](https://developer.wordpress.org/reference/functions/wp_count_attachments/), namely `wp_count_attachments()`. We can filter out images with `wp_count_attachments( $mime_type = 'image' )` that returns an object like: ``` stdClass Object ( [image/gif] => 9 [image/jpeg] => 121 ...
259,647
<p>I would like to disable the "+Add Category Button" under the Category metabox so that anyone creating a post has to choose only from the list of existing categories.</p> <ol> <li><p>I did check out another post, which literally has the same question, <a href="https://wordpress.stackexchange.com/questions/29140/how-...
[ { "answer_id": 259654, "author": "Nathan Johnson", "author_id": 106269, "author_profile": "https://wordpress.stackexchange.com/users/106269", "pm_score": 2, "selected": true, "text": "<blockquote>\n <p>I installed the 'User Role Editor' plugin and removed the 'manage_categories' capabil...
2017/03/10
[ "https://wordpress.stackexchange.com/questions/259647", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111154/" ]
I would like to disable the "+Add Category Button" under the Category metabox so that anyone creating a post has to choose only from the list of existing categories. 1. I did check out another post, which literally has the same question, [How To Remove The "+ Add New Category" Link From A Category Metabox](https://wor...
> > I installed the 'User Role Editor' plugin and removed the 'manage\_categories' capability for the 'Editor' which worked. But I would like to remove it for ALL users including admin, superadmin. > > > If removing the 'manage\_categories' capability from the editor role provides the functionality you want, then ...