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
187,778
<p>I want to create dynamic content that is taken from a specific paragraph from one page and writes to a paragraph on multiple pages that feature that same content. I am new to PHP and not sure how to make this happen in WordPress.</p> <p>I have an existing WordPress webpage, let's call it the Plan, with paragraphs o...
[ { "answer_id": 188273, "author": "ambroseya", "author_id": 72778, "author_profile": "https://wordpress.stackexchange.com/users/72778", "pm_score": 1, "selected": false, "text": "<p>If we can assume that this is done properly for images that are in templates, and you're only concerned abo...
2015/05/08
[ "https://wordpress.stackexchange.com/questions/187778", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/72839/" ]
I want to create dynamic content that is taken from a specific paragraph from one page and writes to a paragraph on multiple pages that feature that same content. I am new to PHP and not sure how to make this happen in WordPress. I have an existing WordPress webpage, let's call it the Plan, with paragraphs on it. The ...
You can try the following test plugin, that uses the [`domDocument`](http://php.net/manual/en/class.domdocument.php) class, to see how it works on your HTML. It assumes PHP 5.4+ with LibXML 2.7.8+. ``` <?php /** * Plugin Name: Add Missing Image Title Attributes * Description: For posts in the main loop (Assumes PHP...
187,789
<p>I have a custom post type called <strong>music</strong>. I have created a custom template as a normal page to show some stats for the musicians. I have a page where they can see all their songs and have added a stats link. The stats link automatically generates URL based on that custom post. </p> <p>An example URL ...
[ { "answer_id": 187798, "author": "Eduardo Sánchez Hidalgo Urías", "author_id": 72745, "author_profile": "https://wordpress.stackexchange.com/users/72745", "pm_score": -1, "selected": false, "text": "<p>I don't Know if I understand the question correctly, but if I do I think this can help...
2015/05/09
[ "https://wordpress.stackexchange.com/questions/187789", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49017/" ]
I have a custom post type called **music**. I have created a custom template as a normal page to show some stats for the musicians. I have a page where they can see all their songs and have added a stats link. The stats link automatically generates URL based on that custom post. An example URL looks like this `https:...
I know that this is old question, but maybe this will help ``` url_to_postid( string $url ) ``` [WP Code reference](https://developer.wordpress.org/reference/functions/url_to_postid/)
187,793
<p>I'm trying to use <a href="https://wordpress.stackexchange.com/a/161227/1685">this answer</a> to order categories based on their Advanced Custom Fields custom field: <code>track_order</code>.</p> <p>I'm able to get the UL to print fine and show the custom field numbers</p> <p><img src="https://i.stack.imgur.com/ZK...
[ { "answer_id": 187798, "author": "Eduardo Sánchez Hidalgo Urías", "author_id": 72745, "author_profile": "https://wordpress.stackexchange.com/users/72745", "pm_score": -1, "selected": false, "text": "<p>I don't Know if I understand the question correctly, but if I do I think this can help...
2015/05/09
[ "https://wordpress.stackexchange.com/questions/187793", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27555/" ]
I'm trying to use [this answer](https://wordpress.stackexchange.com/a/161227/1685) to order categories based on their Advanced Custom Fields custom field: `track_order`. I'm able to get the UL to print fine and show the custom field numbers ![custom categories order image](https://i.stack.imgur.com/ZK6QA.png) but I'...
I know that this is old question, but maybe this will help ``` url_to_postid( string $url ) ``` [WP Code reference](https://developer.wordpress.org/reference/functions/url_to_postid/)
187,831
<p>When a user login, we can easily change the redirect URL (see <a href="https://wordpress.stackexchange.com/questions/59205/user-redirect-to-destination-url-after-login">this</a>, <a href="https://wordpress.stackexchange.com/questions/169704/redirect-to-referring-page-after-logging-in">this</a>, or <a href="https://w...
[ { "answer_id": 187835, "author": "m4n0", "author_id": 70936, "author_profile": "https://wordpress.stackexchange.com/users/70936", "pm_score": 2, "selected": false, "text": "<p>You can check if the current page is login or not using <code>$pagenow</code> global variable and the <code>wp_r...
2015/05/09
[ "https://wordpress.stackexchange.com/questions/187831", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24875/" ]
When a user login, we can easily change the redirect URL (see [this](https://wordpress.stackexchange.com/questions/59205/user-redirect-to-destination-url-after-login), [this](https://wordpress.stackexchange.com/questions/169704/redirect-to-referring-page-after-logging-in), or [this](https://wordpress.stackexchange.com/...
The best way to figure out what's happening for a problem like this is to go to the source. Literally. Take a look in [`wp-login.php`](https://github.com/WordPress/WordPress/blob/4.2.2/wp-login.php) and look for an action that fires before any HTML rendering happens. The hook you're looking for is [`login_init`](https...
187,832
<p>I've been searching for about 2 hours now on a solution of copying/moving <em>selected</em> taxonomy values for each posts to another. Here's the situation.</p> <p>I'm working on a site that has a post type of <code>articles</code> and I'm moving them back to the innate <code>post</code> post type. Within the <code...
[ { "answer_id": 228612, "author": "locomo", "author_id": 42754, "author_profile": "https://wordpress.stackexchange.com/users/42754", "pm_score": 0, "selected": false, "text": "<p>as long as the slugs from your articles taxonomy map exactly to the slugs in your default category you should ...
2015/05/09
[ "https://wordpress.stackexchange.com/questions/187832", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65678/" ]
I've been searching for about 2 hours now on a solution of copying/moving *selected* taxonomy values for each posts to another. Here's the situation. I'm working on a site that has a post type of `articles` and I'm moving them back to the innate `post` post type. Within the `articles`, I've had a taxonomy that was for...
This will get all posts with $old\_tax, copy the terms from $old\_tax to $new\_tax, and then set the $new\_tax terms for those posts. ``` <?php function convert_tax($old_tax, $new_tax) { $pages = get_posts(array( 'post_type' => 'post', 'posts_per_page' => -1, 'tax_query'...
187,849
<p>The original non-wordpress site existed on <a href="http://example.com" rel="nofollow">http://example.com</a>. While building the new site on wordpress, it was built on the wp subdomain: <a href="http://wp.example.com" rel="nofollow">http://wp.example.com</a>. </p> <p>We just moved the original non-wordpress site t...
[ { "answer_id": 228612, "author": "locomo", "author_id": 42754, "author_profile": "https://wordpress.stackexchange.com/users/42754", "pm_score": 0, "selected": false, "text": "<p>as long as the slugs from your articles taxonomy map exactly to the slugs in your default category you should ...
2015/05/09
[ "https://wordpress.stackexchange.com/questions/187849", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15360/" ]
The original non-wordpress site existed on <http://example.com>. While building the new site on wordpress, it was built on the wp subdomain: <http://wp.example.com>. We just moved the original non-wordpress site to <http://example.net> and deleted the original <http://example.com> files. Now in trying to follow the '...
This will get all posts with $old\_tax, copy the terms from $old\_tax to $new\_tax, and then set the $new\_tax terms for those posts. ``` <?php function convert_tax($old_tax, $new_tax) { $pages = get_posts(array( 'post_type' => 'post', 'posts_per_page' => -1, 'tax_query'...
187,852
<p>i want to output html tags in do_shortcode(); function</p> <p><code>&lt;?php echo do_shortcode($content); ?&gt;</code> </p> <p>is it possible? thx!</p>
[ { "answer_id": 187860, "author": "ngearing", "author_id": 50184, "author_profile": "https://wordpress.stackexchange.com/users/50184", "pm_score": 5, "selected": true, "text": "<p>Yes it is possible.</p>\n\n<p>There are two ways that I can think of at this moment. </p>\n\n<p>First follow ...
2015/05/09
[ "https://wordpress.stackexchange.com/questions/187852", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68798/" ]
i want to output html tags in do\_shortcode(); function `<?php echo do_shortcode($content); ?>` is it possible? thx!
Yes it is possible. There are two ways that I can think of at this moment. First follow what the codex says [Shortcodes](https://codex.wordpress.org/Shortcode_API#Output). Basically you just wrap your html in ob\_start(); this will return the html as a string so you can echo it. ``` function my_shortcode() { ob...
187,868
<p>On single custom post types using the <code>single-course.php</code> template I want a different breadcrumb option to happen, but it's not obeying the <code>&amp;&amp;</code> operator in the if statement:</p> <pre><code>&lt;?php if ( function_exists('yoast_breadcrumb') &amp;&amp; !is_page_template( 'single-course.p...
[ { "answer_id": 187871, "author": "Ismail", "author_id": 70833, "author_profile": "https://wordpress.stackexchange.com/users/70833", "pm_score": 3, "selected": true, "text": "<p>You need to include <a href=\"https://codex.wordpress.org/Function_Reference/is_page\" rel=\"nofollow\"><code>i...
2015/05/10
[ "https://wordpress.stackexchange.com/questions/187868", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27555/" ]
On single custom post types using the `single-course.php` template I want a different breadcrumb option to happen, but it's not obeying the `&&` operator in the if statement: ``` <?php if ( function_exists('yoast_breadcrumb') && !is_page_template( 'single-course.php' ) ) { yoast_breadcrumb('<p id="breadcrumbs">','...
You need to include [`is_page()`](https://codex.wordpress.org/Function_Reference/is_page) in your if statement : ``` <?php if ( function_exists('yoast_breadcrumb') && is_page() && !is_page_template( 'single-course.php' ) ) { yoast_breadcrumb('<p id="breadcrumbs">','</p>'); } else { ?> <p id="breadcrumbs"><span...
187,884
<p>I am having an issue that i couldn't find on google and elsewhere. To put problem in the context. I am making a wordpress site where user can put their tutor listing for giving a tutorials, and i am implementing the system of evaluation of the tutors them self and their listening. So I have <em>tutor_listing</em> po...
[ { "answer_id": 237830, "author": "luukvhoudt", "author_id": 44637, "author_profile": "https://wordpress.stackexchange.com/users/44637", "pm_score": 1, "selected": false, "text": "<p>WordPress 4.0 allowed you to specify multiple orderby parameters and set the order of each independently.<...
2015/05/10
[ "https://wordpress.stackexchange.com/questions/187884", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/72885/" ]
I am having an issue that i couldn't find on google and elsewhere. To put problem in the context. I am making a wordpress site where user can put their tutor listing for giving a tutorials, and i am implementing the system of evaluation of the tutors them self and their listening. So I have *tutor\_listing* post type a...
WordPress 4.0 allowed you to specify multiple orderby parameters and set the order of each independently. How to do it? Just make multiple refferences, here is one way to do that. ``` $args = array( 'orderby' = > array( 'title' => 'ASC', 'date' => 'DESC', ) ); ``` [Learn more here...](https:...
187,894
<p>So, I'm a total newbie on BuddyPress and can't seem to understand how is it supposed to work... The question is simple: there is no registration page generated, and even though "Anyone can register" is ticked, when I manually added a login page, there is still no option for registration whatsoever... Any tips would ...
[ { "answer_id": 237830, "author": "luukvhoudt", "author_id": 44637, "author_profile": "https://wordpress.stackexchange.com/users/44637", "pm_score": 1, "selected": false, "text": "<p>WordPress 4.0 allowed you to specify multiple orderby parameters and set the order of each independently.<...
2015/05/10
[ "https://wordpress.stackexchange.com/questions/187894", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69628/" ]
So, I'm a total newbie on BuddyPress and can't seem to understand how is it supposed to work... The question is simple: there is no registration page generated, and even though "Anyone can register" is ticked, when I manually added a login page, there is still no option for registration whatsoever... Any tips would be ...
WordPress 4.0 allowed you to specify multiple orderby parameters and set the order of each independently. How to do it? Just make multiple refferences, here is one way to do that. ``` $args = array( 'orderby' = > array( 'title' => 'ASC', 'date' => 'DESC', ) ); ``` [Learn more here...](https:...
187,898
<p>i'm customzing my admin bar/tool bar and i've added login/logout/lostpassword. but when it comes to the registrations form i've met a brick wall</p> <pre><code>function registration_admin_bar() { global $wp_admin_bar; $wp_admin_bar-&gt;add_menu( array( 'id' =&gt; 'registration-admin-bar', '...
[ { "answer_id": 237830, "author": "luukvhoudt", "author_id": 44637, "author_profile": "https://wordpress.stackexchange.com/users/44637", "pm_score": 1, "selected": false, "text": "<p>WordPress 4.0 allowed you to specify multiple orderby parameters and set the order of each independently.<...
2015/05/10
[ "https://wordpress.stackexchange.com/questions/187898", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69346/" ]
i'm customzing my admin bar/tool bar and i've added login/logout/lostpassword. but when it comes to the registrations form i've met a brick wall ``` function registration_admin_bar() { global $wp_admin_bar; $wp_admin_bar->add_menu( array( 'id' => 'registration-admin-bar', 'parent' => 'top-seco...
WordPress 4.0 allowed you to specify multiple orderby parameters and set the order of each independently. How to do it? Just make multiple refferences, here is one way to do that. ``` $args = array( 'orderby' = > array( 'title' => 'ASC', 'date' => 'DESC', ) ); ``` [Learn more here...](https:...
187,900
<p>I've got the following code that is meant to grab the latest post from each of the provided custom post types (<code>$customTypes</code>), it works on the majority of pages of my site, eg here: <a href="http://trulycode.com/" rel="nofollow">http://trulycode.com/</a> - Notice on the right the grey/yellow/blue boxes s...
[ { "answer_id": 187923, "author": "Alexander Wigmore", "author_id": 19452, "author_profile": "https://wordpress.stackexchange.com/users/19452", "pm_score": 0, "selected": false, "text": "<p>Thanks to the comment by @Pieter Goosen advising it was probably something to do with <code>pre_get...
2015/05/10
[ "https://wordpress.stackexchange.com/questions/187900", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19452/" ]
I've got the following code that is meant to grab the latest post from each of the provided custom post types (`$customTypes`), it works on the majority of pages of my site, eg here: <http://trulycode.com/> - Notice on the right the grey/yellow/blue boxes showing the latest post from the 3 post types. However on archi...
This is an extention to your answer. Your `pre_get_posts` action has a few flaws ``` function add_custom_types_to_tax( $query ) { if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { // Get all your post types $post_types = get_post_types(); $query->set( 'post_type', $pos...
187,961
<p>what i did, </p> <p>i create a search.php </p> <pre><code>&lt;?php get_header(); ?&gt; &lt;div class="wapper"&gt; &lt;div class="contentarea clearfix"&gt; &lt;div class="content"&gt; &lt;h1 class="search-title"&gt; &lt;?php echo $wp_query-&gt;found_posts; ?&gt; &lt;?php _e( 'Search Results Foun...
[ { "answer_id": 187963, "author": "shuvroMithun", "author_id": 65928, "author_profile": "https://wordpress.stackexchange.com/users/65928", "pm_score": 1, "selected": false, "text": "<p>You have to run the loop , modify your search.php something similar to the code below</p>\n\n<pre><code...
2015/05/11
[ "https://wordpress.stackexchange.com/questions/187961", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68799/" ]
what i did, i create a search.php ``` <?php get_header(); ?> <div class="wapper"> <div class="contentarea clearfix"> <div class="content"> <h1 class="search-title"> <?php echo $wp_query->found_posts; ?> <?php _e( 'Search Results Found For', 'locale' ); ?>: "<?php the_search_query(); ?>" </h1> ...
I have some recommendations for your question: **First**: stop using `query_posts()`. See [the codex about this function](https://codex.wordpress.org/Function_Reference/query_posts) to see why you shouldn't use it in themes or plugins. Anyway, if you are in a some weird situation where you have not option and you need...
187,962
<p>I'm using the following if statements within header.php to load custom tracking codes.</p> <pre><code>&lt;?php if ( is_singular( array( 'custom-post-type', 'post-name' ) ) ) : ?&gt; // Specific tracking code here &lt;?php endif ?&gt; &lt;?php if ( is_singular( array( 'custom-post-type', 'another-post' ) ) ) :...
[ { "answer_id": 187964, "author": "JimboSlice", "author_id": 64223, "author_profile": "https://wordpress.stackexchange.com/users/64223", "pm_score": 2, "selected": false, "text": "<p>I think you have over complicated your parameter for \"is_singular\", or is \"custom-post-type\" an actual...
2015/05/11
[ "https://wordpress.stackexchange.com/questions/187962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37548/" ]
I'm using the following if statements within header.php to load custom tracking codes. ``` <?php if ( is_singular( array( 'custom-post-type', 'post-name' ) ) ) : ?> // Specific tracking code here <?php endif ?> <?php if ( is_singular( array( 'custom-post-type', 'another-post' ) ) ) : ?> // Specific tracking ...
You are using an incorrect check here. [`is_singular()`](https://codex.wordpress.org/Function_Reference/is_singular) returns true when a post is from the specified post type or post types or the default post types when none is specified. You cannot target specific single posts with `is_singular()` You have to use [`is...
188,027
<p>I want to automatically get products from woocommerce for a chosen brand, inside a brand's listing on a other part of the site using Sabai Directory.</p> <p>this</p> <pre><code>&lt;?php Sabai::_h($entity-&gt;getSlug());?&gt; </code></pre> <p>stamp listing slug on the page</p> <p>The plugin shortcode pick a list ...
[ { "answer_id": 187964, "author": "JimboSlice", "author_id": 64223, "author_profile": "https://wordpress.stackexchange.com/users/64223", "pm_score": 2, "selected": false, "text": "<p>I think you have over complicated your parameter for \"is_singular\", or is \"custom-post-type\" an actual...
2015/05/11
[ "https://wordpress.stackexchange.com/questions/188027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/72960/" ]
I want to automatically get products from woocommerce for a chosen brand, inside a brand's listing on a other part of the site using Sabai Directory. this ``` <?php Sabai::_h($entity->getSlug());?> ``` stamp listing slug on the page The plugin shortcode pick a list of product of a chosen brand ``` [shortcode_prod...
You are using an incorrect check here. [`is_singular()`](https://codex.wordpress.org/Function_Reference/is_singular) returns true when a post is from the specified post type or post types or the default post types when none is specified. You cannot target specific single posts with `is_singular()` You have to use [`is...
188,037
<p>So, I have following markup to show a shortcode:</p> <pre><code>&lt;div class="my_edit_button"&gt; &lt;?php echo do_shortcode('[something]'); ?&gt; &lt;/div&gt; </code></pre> <p>Then I am trying to make it so that the shortcode is only shown to post author by using the following:</p> <pre><code>return ($post-...
[ { "answer_id": 188040, "author": "Wali Hassan", "author_id": 72947, "author_profile": "https://wordpress.stackexchange.com/users/72947", "pm_score": 2, "selected": true, "text": "<p>Try this</p>\n\n<pre><code>&lt;div class=\"my_edit_button\"&gt;\n&lt;?php if ( $post-&gt;post_author == $c...
2015/05/11
[ "https://wordpress.stackexchange.com/questions/188037", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67604/" ]
So, I have following markup to show a shortcode: ``` <div class="my_edit_button"> <?php echo do_shortcode('[something]'); ?> </div> ``` Then I am trying to make it so that the shortcode is only shown to post author by using the following: ``` return ($post->post_author == $current_user->ID); ``` But I am not ...
Try this ``` <div class="my_edit_button"> <?php if ( $post->post_author == $current_user->ID ) { echo do_shortcode('[something]'); }?> </div> ```
188,039
<p>The main site</p> <pre><code>https://www.ptacunits.com </code></pre> <p>loads fine. We have a CNAME pointing from the above domain to the following domain, </p> <pre><code>https://www.ptacfactoryparts.com </code></pre> <p>however, the page source shows HTTP for all the asset files. Even the Google Font which is...
[ { "answer_id": 188040, "author": "Wali Hassan", "author_id": 72947, "author_profile": "https://wordpress.stackexchange.com/users/72947", "pm_score": 2, "selected": true, "text": "<p>Try this</p>\n\n<pre><code>&lt;div class=\"my_edit_button\"&gt;\n&lt;?php if ( $post-&gt;post_author == $c...
2015/05/11
[ "https://wordpress.stackexchange.com/questions/188039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68982/" ]
The main site ``` https://www.ptacunits.com ``` loads fine. We have a CNAME pointing from the above domain to the following domain, ``` https://www.ptacfactoryparts.com ``` however, the page source shows HTTP for all the asset files. Even the Google Font which is hard coded as HTTPs ``` //fonts.googleapis.com/...
Try this ``` <div class="my_edit_button"> <?php if ( $post->post_author == $current_user->ID ) { echo do_shortcode('[something]'); }?> </div> ```
188,084
<p>I reckon this one is quick and easy... I think I'm just missing something very obvious. My inquiry is nearly identical to <a href="https://stackoverflow.com/questions/23800440/removed-mine-filter-and-want-to-make-all-be-default-on-post-page">this stackoverflow post</a>. </p> <p>For non-admin users, the default fi...
[ { "answer_id": 188109, "author": "zk87", "author_id": 70893, "author_profile": "https://wordpress.stackexchange.com/users/70893", "pm_score": 3, "selected": true, "text": "<p>answer ^^</p>\n\n<pre><code>add_action( 'load-edit.php', function() \n{\nglobal $typenow;\n\n// Not our post type...
2015/05/12
[ "https://wordpress.stackexchange.com/questions/188084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70893/" ]
I reckon this one is quick and easy... I think I'm just missing something very obvious. My inquiry is nearly identical to [this stackoverflow post](https://stackoverflow.com/questions/23800440/removed-mine-filter-and-want-to-make-all-be-default-on-post-page). For non-admin users, the default filter for posts is 'mine...
answer ^^ ``` add_action( 'load-edit.php', function() { global $typenow; // Not our post type, bail out if( 'community' !== $typenow ) return; // Administrator users don't need this, bail out if( current_user_can('add_users') ) return; // Only the Mine tab fills this conditions, redirect if( !isset( $_GET[...
188,104
<p>I've been asked to implement a custom redirection in WordPress. It seemed quite simple at first but I have no idea how to get it right. So much that I can't even get started with it. This is how it should go:</p> <ul> <li>The user logs in, and the database gets queried using the <code>wp_login</code> hook</li> <li>...
[ { "answer_id": 188109, "author": "zk87", "author_id": 70893, "author_profile": "https://wordpress.stackexchange.com/users/70893", "pm_score": 3, "selected": true, "text": "<p>answer ^^</p>\n\n<pre><code>add_action( 'load-edit.php', function() \n{\nglobal $typenow;\n\n// Not our post type...
2015/05/12
[ "https://wordpress.stackexchange.com/questions/188104", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/72991/" ]
I've been asked to implement a custom redirection in WordPress. It seemed quite simple at first but I have no idea how to get it right. So much that I can't even get started with it. This is how it should go: * The user logs in, and the database gets queried using the `wp_login` hook * If a certain condition is met, t...
answer ^^ ``` add_action( 'load-edit.php', function() { global $typenow; // Not our post type, bail out if( 'community' !== $typenow ) return; // Administrator users don't need this, bail out if( current_user_can('add_users') ) return; // Only the Mine tab fills this conditions, redirect if( !isset( $_GET[...
188,167
<p>I'm setting up jQuery UI on one of my WordPress pages that uses a custom template (course-landing-page.php). I enqueued the scripts for jQuery UI the proper way, but I need to add a JavaScript snippet AFTER the scripts in order to register the tabs on the page.</p> <p>This is what the code in my functions.php file ...
[ { "answer_id": 188168, "author": "DigitalSky", "author_id": 47430, "author_profile": "https://wordpress.stackexchange.com/users/47430", "pm_score": 0, "selected": false, "text": "<p>Ahh, solved it with this!</p>\n\n<pre><code>add_action( 'wp_head', 'jQuery_UI_Tabs' );\nfunction jQuery_UI...
2015/05/12
[ "https://wordpress.stackexchange.com/questions/188167", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47430/" ]
I'm setting up jQuery UI on one of my WordPress pages that uses a custom template (course-landing-page.php). I enqueued the scripts for jQuery UI the proper way, but I need to add a JavaScript snippet AFTER the scripts in order to register the tabs on the page. This is what the code in my functions.php file looks like...
You should use the [`wp_enqueue_script()`](https://developer.wordpress.org/reference/functions/wp_enqueue_script/) function and the dependency parameter to ensure scripts are loaded in the appropriate order, and if you're adamant in using inline scripts, you can add it with the [`wp_add_inline_script()`](https://develo...
188,187
<p>I have properly set up a child theme and am adding stylesheets and scripts in my new functions.php file. The only problem is, my newly enqueued stylesheets are being referenced using the parent theme when the files are located in the child theme folder.</p> <p>Setting up child theme:</p> <pre><code>&lt;?php ad...
[ { "answer_id": 188168, "author": "DigitalSky", "author_id": 47430, "author_profile": "https://wordpress.stackexchange.com/users/47430", "pm_score": 0, "selected": false, "text": "<p>Ahh, solved it with this!</p>\n\n<pre><code>add_action( 'wp_head', 'jQuery_UI_Tabs' );\nfunction jQuery_UI...
2015/05/13
[ "https://wordpress.stackexchange.com/questions/188187", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62370/" ]
I have properly set up a child theme and am adding stylesheets and scripts in my new functions.php file. The only problem is, my newly enqueued stylesheets are being referenced using the parent theme when the files are located in the child theme folder. Setting up child theme: ``` <?php add_action( 'wp_enqueue_sc...
You should use the [`wp_enqueue_script()`](https://developer.wordpress.org/reference/functions/wp_enqueue_script/) function and the dependency parameter to ensure scripts are loaded in the appropriate order, and if you're adamant in using inline scripts, you can add it with the [`wp_add_inline_script()`](https://develo...
188,250
<p>I've replaced the WP search on my site with a Google CSE. Google has a nice feature that lets you specify that certain areas of the page should not be indexable, by adding a "nocontent" class to those sections. I need to add this class to all the sidebars.</p> <p>I've tried adding a filter to register_sidebar, and ...
[ { "answer_id": 188168, "author": "DigitalSky", "author_id": 47430, "author_profile": "https://wordpress.stackexchange.com/users/47430", "pm_score": 0, "selected": false, "text": "<p>Ahh, solved it with this!</p>\n\n<pre><code>add_action( 'wp_head', 'jQuery_UI_Tabs' );\nfunction jQuery_UI...
2015/05/13
[ "https://wordpress.stackexchange.com/questions/188250", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65652/" ]
I've replaced the WP search on my site with a Google CSE. Google has a nice feature that lets you specify that certain areas of the page should not be indexable, by adding a "nocontent" class to those sections. I need to add this class to all the sidebars. I've tried adding a filter to register\_sidebar, and the data ...
You should use the [`wp_enqueue_script()`](https://developer.wordpress.org/reference/functions/wp_enqueue_script/) function and the dependency parameter to ensure scripts are loaded in the appropriate order, and if you're adamant in using inline scripts, you can add it with the [`wp_add_inline_script()`](https://develo...
188,267
<p>I am trying to save a revision of a custom post type. This is what I have to check if the post has a parent:</p> <pre><code>function save_revision( $post ) { if ( $post['submitted'] == true ) { $parent_id = wp_is_post_revision( $post['post_id'] ); ... } } add_action('init', 'save_revision'); ...
[ { "answer_id": 188269, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 1, "selected": false, "text": "<p>It is simple: If <code>$post</code> is not a revision, <code>wp_is_post_revision()</code> returns false; just...
2015/05/13
[ "https://wordpress.stackexchange.com/questions/188267", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54189/" ]
I am trying to save a revision of a custom post type. This is what I have to check if the post has a parent: ``` function save_revision( $post ) { if ( $post['submitted'] == true ) { $parent_id = wp_is_post_revision( $post['post_id'] ); ... } } add_action('init', 'save_revision'); ``` The prob...
I know this is an old thread, but for future reference - the term "revision" in Wordpress is a little confusing. It's not the updated, *or revised*, post... but the older version. The most updated version is the "parent." So, if you're calling the function `wp_is_revision_post()` on the current version of the post, it...
188,287
<p>I have the following wp_query:</p> <pre><code>$args = array( 'post_type' =&gt; 'news', 'orderby' =&gt; 'meta_key', 'order' =&gt; 'ASC', 'meta_key'=&gt;'custom_author_name', 'post_per_page'=&gt;-1 ); $query = new WP_Query($args); echo $query-&gt;found_posts; </code></pre> <p>echo = 10 results ...
[ { "answer_id": 188301, "author": "ambroseya", "author_id": 72778, "author_profile": "https://wordpress.stackexchange.com/users/72778", "pm_score": 1, "selected": false, "text": "<p>That's actually how it works. </p>\n\n<p>If you want to do that without adding table rows, you'll have to d...
2015/05/13
[ "https://wordpress.stackexchange.com/questions/188287", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/30984/" ]
I have the following wp\_query: ``` $args = array( 'post_type' => 'news', 'orderby' => 'meta_key', 'order' => 'ASC', 'meta_key'=>'custom_author_name', 'post_per_page'=>-1 ); $query = new WP_Query($args); echo $query->found_posts; ``` echo = 10 results because there are only 10 `news` posts with...
As stated in @ambroseya's answer, its supposed to work like that. Once you declare a meta query, even if you aren't looking for a specific value, it will only query posts with that meta key declared. If you want to include all posts sort them by the meta key, use the following code: ``` $args = array( 'post_type' ...
188,292
<p>I am using a plugin called events manager. There is a custom post type called events, &amp; each event has a date in a custom field. There is also a custom taxonomy called event categories.</p> <p>On my site, all the events that have been assigned to a term in the event categories taxonomy, have an archive page. My...
[ { "answer_id": 188294, "author": "Tuan Anh Hoang-Vu", "author_id": 2222, "author_profile": "https://wordpress.stackexchange.com/users/2222", "pm_score": 2, "selected": true, "text": "<p>If you store the event start date in <code>_event_start_date</code>, then you can check the value of t...
2015/05/14
[ "https://wordpress.stackexchange.com/questions/188292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am using a plugin called events manager. There is a custom post type called events, & each event has a date in a custom field. There is also a custom taxonomy called event categories. On my site, all the events that have been assigned to a term in the event categories taxonomy, have an archive page. My code below sh...
If you store the event start date in `_event_start_date`, then you can check the value of this field against current date: ``` if (strtotime(get_post_meta($id, '_event_start_date', true)) > time()){ // future event } else { // past event } ```
188,296
<p>So I'm using this filter in order to shorten the title:</p> <pre><code>function the_titlesmall($before = '', $after = '', $echo = true, $length = false) { $title = get_the_title(); if ( $length &amp;&amp; is_numeric($length) ) { $title = substr( $title, 0, $length ); } if ( strlen($title)&gt; 0 ) { $title...
[ { "answer_id": 188300, "author": "ambroseya", "author_id": 72778, "author_profile": "https://wordpress.stackexchange.com/users/72778", "pm_score": 0, "selected": false, "text": "<p>Instead of having it be an \"after\" variable, add the ... where you are cutting the substring. Check the l...
2015/05/14
[ "https://wordpress.stackexchange.com/questions/188296", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21245/" ]
So I'm using this filter in order to shorten the title: ``` function the_titlesmall($before = '', $after = '', $echo = true, $length = false) { $title = get_the_title(); if ( $length && is_numeric($length) ) { $title = substr( $title, 0, $length ); } if ( strlen($title)> 0 ) { $title = apply_filters('the_tit...
Try this. First check if the original string length is less than or equal to passed in length, and if so, we ignore the `$after` parameter : ``` function the_titlesmall($before = '', $after = '', $echo = true, $length = false) { $title = get_the_title(); if( strlen($title) <= $length ) $after = ''; if...
188,308
<p>I am trying to create a hook that when a user login, it check the user role.. if the user role is <code>jsa_contributor</code> then it redirect into specific page. but it seems my code didn't work.</p> <p>This is the code..</p> <pre><code>function my_login_redirect($login) { $data_login = get_option('axl_jsa_l...
[ { "answer_id": 188309, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 5, "selected": true, "text": "<p>OK, so your first problem is that <code>$current_user-&gt;roles</code> is an array and not a string, s...
2015/05/14
[ "https://wordpress.stackexchange.com/questions/188308", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68933/" ]
I am trying to create a hook that when a user login, it check the user role.. if the user role is `jsa_contributor` then it redirect into specific page. but it seems my code didn't work. This is the code.. ``` function my_login_redirect($login) { $data_login = get_option('axl_jsa_login_wid_setup'); $redirect_...
OK, so your first problem is that `$current_user->roles` is an array and not a string, so your condition won't be true ;) My another concern would be the hook you're using. Some plugins may use it for other purposes, and killing the script can be harmful. And... there is much better hook for this ;) First solution: u...
188,317
<p>On my site several filters should be applied if the user is viewing the static home page. My understanding is that <a href="https://codex.wordpress.org/Function_Reference/is_front_page" rel="nofollow noreferrer"><code>is_front_page()</code></a> should determine if that is indeed the case.</p> <p>However, whenever I...
[ { "answer_id": 188320, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p>Regarding the <code>posts_orderby</code>, <code>posts_where</code>, <code>posts_join</code> and <code>posts_cl...
2015/05/14
[ "https://wordpress.stackexchange.com/questions/188317", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10097/" ]
On my site several filters should be applied if the user is viewing the static home page. My understanding is that [`is_front_page()`](https://codex.wordpress.org/Function_Reference/is_front_page) should determine if that is indeed the case. However, whenever I use the function I find that sometimes it returns `true` ...
Regarding the `posts_orderby`, `posts_where`, `posts_join` and `posts_clauses` hooks, the current `\WP_Query` object is available through the *second* input argument. These are the relevant parts from the `\WP_Query` class: ``` $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); $where ...
188,332
<p>WordPress is set to Dutch language. When I use <code>get_the_archive_title()</code> my theme correctly outputs "Categorie: Category-name" on a category archive page. However I'd like that to read "Sectie: Category-name". </p> <p>I do not want to change the Dutch language file in the wp-content/languages folder, bec...
[ { "answer_id": 188339, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 6, "selected": true, "text": "<p>You could use <a href=\"https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext\" rel=\"noreferrer\">g...
2015/05/14
[ "https://wordpress.stackexchange.com/questions/188332", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10595/" ]
WordPress is set to Dutch language. When I use `get_the_archive_title()` my theme correctly outputs "Categorie: Category-name" on a category archive page. However I'd like that to read "Sectie: Category-name". I do not want to change the Dutch language file in the wp-content/languages folder, because that will be upd...
You could use [gettext filter](https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext): ``` add_filter( 'gettext', 'cyb_filter_gettext', 10, 3 ); function cyb_filter_gettext( $translated, $original, $domain ) { // Use the text string exactly as it is in the translation file if ( $translated == "Categ...
188,335
<p>I am using Wordpress gallery in a theme.</p> <p>I am trying to change the order of images by changing the order of ids but it is not working for me. I have searched relative questions to wordpress gallery but nothing is working for me.</p> <p>I also have deactive all the plugins. I also do not have install any pos...
[ { "answer_id": 188347, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Add <code>order</code> and/or <code>orderby</code> parameters to your shortcode. For example:</p>\n\n<pre><c...
2015/05/14
[ "https://wordpress.stackexchange.com/questions/188335", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65549/" ]
I am using Wordpress gallery in a theme. I am trying to change the order of images by changing the order of ids but it is not working for me. I have searched relative questions to wordpress gallery but nothing is working for me. I also have deactive all the plugins. I also do not have install any post type order plug...
Add `order` and/or `orderby` parameters to your shortcode. For example: ``` [gallery columns="4" ids="310,309,311,312,315,314,313" order="DESC" orderby="ID"] ``` <https://codex.wordpress.org/Gallery_Shortcode#Options>
188,384
<p>I need to delete some content from all posts.</p> <p>Every post starts with this line:</p> <pre><code>&lt;p style="text-align: center;"&gt;&lt;img src="http://i.imgur.com/picture.jpg" alt="" /&gt;&lt;/p&gt; </code></pre> <p>So I want to delete this line from all posts from my database at once.</p> <p>I know I ca...
[ { "answer_id": 188398, "author": "Wali Hassan", "author_id": 72947, "author_profile": "https://wordpress.stackexchange.com/users/72947", "pm_score": 2, "selected": false, "text": "<p>To use phpMyAdmin follow the steps below:</p>\n\n<pre><code>Login to phpMyAdmin panel and select your Wor...
2015/05/14
[ "https://wordpress.stackexchange.com/questions/188384", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73119/" ]
I need to delete some content from all posts. Every post starts with this line: ``` <p style="text-align: center;"><img src="http://i.imgur.com/picture.jpg" alt="" /></p> ``` So I want to delete this line from all posts from my database at once. I know I can edit it in phpmyadmin but I do not know how to do it. H...
To use phpMyAdmin follow the steps below: ``` Login to phpMyAdmin panel and select your WordPress database. Click on the SQL tab which will bring you to a page with a SQL query box. ``` Once you see the SQL query box, like the image shown below, you can run your SQL query there. ``` UPDATE wp_posts SET post_content...
188,402
<p>I tried to use AngularJS with the plugin JSON API. I have no error but the route doesn't work, and the page doesn't print the partials/... ?</p> <p>I changed the permalinks to <code>%postName%</code>.</p> <p>I use MAMP and my link is: <code>http://localhost:8888/angular-wp</code>. </p> <p>The JSON content works: ...
[ { "answer_id": 191164, "author": "Pim Schaaf", "author_id": 25886, "author_profile": "https://wordpress.stackexchange.com/users/25886", "pm_score": 2, "selected": true, "text": "<p>Doublecheck if there’s a “nobase” error in your console. If so, according to the AngularJS documentation, a...
2015/05/14
[ "https://wordpress.stackexchange.com/questions/188402", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73133/" ]
I tried to use AngularJS with the plugin JSON API. I have no error but the route doesn't work, and the page doesn't print the partials/... ? I changed the permalinks to `%postName%`. I use MAMP and my link is: `http://localhost:8888/angular-wp`. The JSON content works: `http://localhost:8888/angular-wp/api/get_post...
Doublecheck if there’s a “nobase” error in your console. If so, according to the AngularJS documentation, and [fix.io](https://1fix.io/blog/2014/11/05/angularjs-json-api-wp-theme/) (credits for this answer go to [the author of that post](https://1fix.io/blog/author/admin/)) the base tag is to the rescue. ``` <html ng...
188,431
<p>quick question: I'm using a plugin that creates a custom-post-type with the rewrite slug /projects/</p> <p>So <code>myurl.com/projects/single-project</code></p> <p>I want to to rewrite `projects/ with </p> <p><code>'rewrite' =&gt; array('slug'=&gt;''),</code></p> <p>Is there a hook or something so that I can hoo...
[ { "answer_id": 188932, "author": "Page Carbajal", "author_id": 73404, "author_profile": "https://wordpress.stackexchange.com/users/73404", "pm_score": 2, "selected": false, "text": "<p>Are you calling flush_rewrite_rules at any moment?</p>\n\n<p>If you are going to change the slug of a c...
2015/05/15
[ "https://wordpress.stackexchange.com/questions/188431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
quick question: I'm using a plugin that creates a custom-post-type with the rewrite slug /projects/ So `myurl.com/projects/single-project` I want to to rewrite `projects/ with `'rewrite' => array('slug'=>''),` Is there a hook or something so that I can hook to for the `register_post_type()` function of the externa...
I searched everywhere in post type registration flow but didn't found a right way (using filter or action) to do it. All you can do either register the post type again with a different slug (I prefer) or just run those lines of code which WordPress run to build the rewrite rules in register\_post\_type. I register th...
188,436
<p>in wordpress version 3.6 and 3.7 everything works great, but with version 4 and above I get:</p> <pre><code>Cannot modify header information - headers already sent </code></pre> <p>the problem line is:</p> <pre><code>header('Location: '. $redirect </code></pre> <p>Is there some security script in the new versio...
[ { "answer_id": 188453, "author": "mirage", "author_id": 22505, "author_profile": "https://wordpress.stackexchange.com/users/22505", "pm_score": 0, "selected": false, "text": "<p>Probably a plugin conflict. Rename your plugin folder to disable all plugins and see if the problem still pers...
2015/05/15
[ "https://wordpress.stackexchange.com/questions/188436", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41168/" ]
in wordpress version 3.6 and 3.7 everything works great, but with version 4 and above I get: ``` Cannot modify header information - headers already sent ``` the problem line is: ``` header('Location: '. $redirect ``` Is there some security script in the new version? How can i override it?
Use [`wp_redirect()`](https://codex.wordpress.org/Function_Reference/wp_redirect) function instead of `header()`. Here is the code example: ``` wp_redirect($redirect); ```
188,448
<p>What's the difference between <code>get_home_path()</code> and <code>ABSPATH</code>? Isn't the point of both to point to the WordPress install root?</p>
[ { "answer_id": 188461, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 6, "selected": true, "text": "<p>They <strong><em>should</em></strong> do the same thing, but under certain conditions, may not.</p>\n\n<p>First o...
2015/05/15
[ "https://wordpress.stackexchange.com/questions/188448", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12248/" ]
What's the difference between `get_home_path()` and `ABSPATH`? Isn't the point of both to point to the WordPress install root?
They ***should*** do the same thing, but under certain conditions, may not. First of all note: * that the [codex](https://codex.wordpress.org/Function_Reference/get_home_path) entry description is misleading * that [`wp-admin/includes/file.php`](https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/fil...
188,467
<p>Please take a look at the loops below, I'm having issues trying to order the attachment by title, name, and modified. </p> <pre><code>&lt;?php foreach ($instance['data'] as $id) : $args = array( 'include' =&gt; $id, ...
[ { "answer_id": 188471, "author": "Wali Hassan", "author_id": 72947, "author_profile": "https://wordpress.stackexchange.com/users/72947", "pm_score": 0, "selected": false, "text": "<p>Like I said, in your custom scenario, after getting the results, here is your how you can do it:</p>\n\n<...
2015/05/15
[ "https://wordpress.stackexchange.com/questions/188467", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26988/" ]
Please take a look at the loops below, I'm having issues trying to order the attachment by title, name, and modified. ``` <?php foreach ($instance['data'] as $id) : $args = array( 'include' => $id, ...
You don't get any ordering, because you are making multiple `get_posts()` calls and only retrieve a *single* post in each of them. You cannot order a single post. :) You need to get rid of outermost loop and just pass a *set* of IDs (that would be your `$instance['data']`) to retrieve via single `get_posts()` call.
188,473
<p>I am trying to build a villa rentals website. To achieve that, I have created two custom post types. The one is named "villa" and is used to show the villas for rent, and the other one is named "destinations" and is used to show the places where this villas are. </p> <p>I used the <a href="https://wordpress.org/pl...
[ { "answer_id": 188559, "author": "ngearing", "author_id": 50184, "author_profile": "https://wordpress.stackexchange.com/users/50184", "pm_score": 0, "selected": false, "text": "<p>So to achieve your 2 issues all we have to do is modify the $args array that is being used for the Query. Be...
2015/05/15
[ "https://wordpress.stackexchange.com/questions/188473", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73164/" ]
I am trying to build a villa rentals website. To achieve that, I have created two custom post types. The one is named "villa" and is used to show the villas for rent, and the other one is named "destinations" and is used to show the places where this villas are. I used the [CPT-onomies](https://wordpress.org/plugins/...
I would just just scrap the function above as there are several bugs in the code and is also not quite effecient. I am actually surpriced that it really works for you. Your best solution here would be to write a complete new function. Here is want we want to do and how we are going to accomplish this * Get the curren...
188,474
<p>I use the WordPress heartbeat to check a setting on my server from the front-end. If that setting has a specific value I want to stop bothering the server. There for I want to stop/pause the heartbeat. There are no other things depending on the heartbeat.</p> <p>I found <em>wp.heartbeat.stop()</em> <a href="https:/...
[ { "answer_id": 189483, "author": "ryanm", "author_id": 73665, "author_profile": "https://wordpress.stackexchange.com/users/73665", "pm_score": 1, "selected": false, "text": "<p>Drivingralle,</p>\n\n<p>You are on the right trail here with your code.</p>\n\n<p>I've done some work in the Ja...
2015/05/15
[ "https://wordpress.stackexchange.com/questions/188474", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45303/" ]
I use the WordPress heartbeat to check a setting on my server from the front-end. If that setting has a specific value I want to stop bothering the server. There for I want to stop/pause the heartbeat. There are no other things depending on the heartbeat. I found *wp.heartbeat.stop()* [over here](https://wordpress.sta...
Drivingralle, You are on the right trail here with your code. I've done some work in the JavaScript console, and my conclusion from debugging `heartbeat.min.js` temporarily (source came from `heartbeat.js`) is that settings.suspend **is** properly triggered on the 'unload.wp-heartbeat' event. However, I believe it to...
188,480
<p>I'm working on a custom post type. I have the editor enabled but the content that will go in that box is secondary and it isn't clear what should be typed there so I want to add a label for the editor. How do I do that?</p>
[ { "answer_id": 188483, "author": "Wali Hassan", "author_id": 72947, "author_profile": "https://wordpress.stackexchange.com/users/72947", "pm_score": 2, "selected": false, "text": "<p>I recently used this in one of the projects, so here you go</p>\n\n<pre><code>add_action( 'edit_form_afte...
2015/05/15
[ "https://wordpress.stackexchange.com/questions/188480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67366/" ]
I'm working on a custom post type. I have the editor enabled but the content that will go in that box is secondary and it isn't clear what should be typed there so I want to add a label for the editor. How do I do that?
After hacking around, this is the solution I came up with: At the top of `functions.php` I have the following line: ``` add_action('admin_footer', 'add_title_to_editor'); ``` Just thrown in the middle of `functions.php` I have the following function: ``` function add_title_to_editor() { global $post; if (g...
188,495
<p>Currently I do:</p> <pre><code>$options = get_option( 'jons-plugin-options' ); echo "&lt;input id='jons-plugin-options[field-two]' name='jons-plugin-options[field-two]' size='4' type='text' value='" . $options['field-two'] . "' /&gt;"; </code></pre> <p>But it does not get the submitted form value and displ...
[ { "answer_id": 188483, "author": "Wali Hassan", "author_id": 72947, "author_profile": "https://wordpress.stackexchange.com/users/72947", "pm_score": 2, "selected": false, "text": "<p>I recently used this in one of the projects, so here you go</p>\n\n<pre><code>add_action( 'edit_form_afte...
2015/05/16
[ "https://wordpress.stackexchange.com/questions/188495", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17642/" ]
Currently I do: ``` $options = get_option( 'jons-plugin-options' ); echo "<input id='jons-plugin-options[field-two]' name='jons-plugin-options[field-two]' size='4' type='text' value='" . $options['field-two'] . "' />"; ``` But it does not get the submitted form value and display it when I do: ``` add_setti...
After hacking around, this is the solution I came up with: At the top of `functions.php` I have the following line: ``` add_action('admin_footer', 'add_title_to_editor'); ``` Just thrown in the middle of `functions.php` I have the following function: ``` function add_title_to_editor() { global $post; if (g...
188,504
<p>How Do I get the ID of latest 10 pages from a certain category in my wordpress blog. Please suggest me a relevant function to get that in a form f array or something that could give me the ID's of latest 10 pages of my blog.</p>
[ { "answer_id": 188507, "author": "KC Chai", "author_id": 26988, "author_profile": "https://wordpress.stackexchange.com/users/26988", "pm_score": 2, "selected": false, "text": "<p>Try the code below. This is the Reference: <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query\" r...
2015/05/16
[ "https://wordpress.stackexchange.com/questions/188504", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73182/" ]
How Do I get the ID of latest 10 pages from a certain category in my wordpress blog. Please suggest me a relevant function to get that in a form f array or something that could give me the ID's of latest 10 pages of my blog.
Try the code below. This is the Reference: [`WP_Query`](https://codex.wordpress.org/Class_Reference/WP_Query) ``` <?php $args = array( 'post_type' => 'page', 'posts_per_page' => 10, 'category_name' => 'mycat', 'fields' => 'ids' ); $data = get_posts($args); print_r($data); `...
188,567
<p>I'm working in the WordPress admin area on my smartphone.</p> <h2>Where are the screen options?</h2> <p>I need to &quot;Show advanced menu properties&quot;.</p>
[ { "answer_id": 188569, "author": "Johann", "author_id": 21245, "author_profile": "https://wordpress.stackexchange.com/users/21245", "pm_score": 1, "selected": false, "text": "<p>If the screen is less than 782px, \"Screen Options\" are hidden.</p>\n\n<pre><code>@media screen and (max-widt...
2015/05/17
[ "https://wordpress.stackexchange.com/questions/188567", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm working in the WordPress admin area on my smartphone. Where are the screen options? ----------------------------- I need to "Show advanced menu properties".
If the screen is less than 782px, "Screen Options" are hidden. ``` @media screen and (max-width: 782px) { #collapse-menu, #screen-meta, #screen-meta-links, .post-format-select { display: none!important; } } ```
188,599
<p>There is a plugin that is loading ajax actions like so:</p> <pre><code>add_action( 'wp_ajax_nopriv_func_name', array( &amp;$this, 'func_name' ) ); add_action( 'wp_ajax_get_func_name', array( &amp;$this, 'func_name' ) ); </code></pre> <p>I want to remove them in my theme so I am doing:</p> <pre><code>remove_all_ac...
[ { "answer_id": 188603, "author": "Guerrilla", "author_id": 70230, "author_profile": "https://wordpress.stackexchange.com/users/70230", "pm_score": 2, "selected": false, "text": "<p>The main issue I was having is that when an ajax request hits not all hooks are being loaded. </p>\n\n<p>I...
2015/05/17
[ "https://wordpress.stackexchange.com/questions/188599", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70230/" ]
There is a plugin that is loading ajax actions like so: ``` add_action( 'wp_ajax_nopriv_func_name', array( &$this, 'func_name' ) ); add_action( 'wp_ajax_get_func_name', array( &$this, 'func_name' ) ); ``` I want to remove them in my theme so I am doing: ``` remove_all_actions('wp_ajax_nopriv_func_name'); remove_all...
The main issue I was having is that when an ajax request hits not all hooks are being loaded. I used this code: ``` $return = array(); foreach( $GLOBALS['wp_actions'] as $action => $count ) { $return["message"] .= $action . ", "; } wp_send_json($return); ``` This showed me the hooks that were running before an...
188,600
<p>I'm trying to update post meta in an acf repeater fields have value using this function, but it's not working:</p> <pre><code>function save_photos_meta_data( $post_id ) { if( get_field('photos') ) { update_post_meta( $post_id, 'has_images', 'yes' ); } else { update_post_meta( $post_id, 'has_...
[ { "answer_id": 188603, "author": "Guerrilla", "author_id": 70230, "author_profile": "https://wordpress.stackexchange.com/users/70230", "pm_score": 2, "selected": false, "text": "<p>The main issue I was having is that when an ajax request hits not all hooks are being loaded. </p>\n\n<p>I...
2015/05/17
[ "https://wordpress.stackexchange.com/questions/188600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37529/" ]
I'm trying to update post meta in an acf repeater fields have value using this function, but it's not working: ``` function save_photos_meta_data( $post_id ) { if( get_field('photos') ) { update_post_meta( $post_id, 'has_images', 'yes' ); } else { update_post_meta( $post_id, 'has_images', 'no' ...
The main issue I was having is that when an ajax request hits not all hooks are being loaded. I used this code: ``` $return = array(); foreach( $GLOBALS['wp_actions'] as $action => $count ) { $return["message"] .= $action . ", "; } wp_send_json($return); ``` This showed me the hooks that were running before an...
188,624
<p>I am Using Wordpress for making a website and getting below Error only on my pages and No shortcodes are working due to this error. This error ONLY seen on PAGES they are working fine on POSTS. I don't know the solution of this error please help me out. I am new to wordpress.</p> <p><strong>Error:</strong></p> <p>...
[ { "answer_id": 188603, "author": "Guerrilla", "author_id": 70230, "author_profile": "https://wordpress.stackexchange.com/users/70230", "pm_score": 2, "selected": false, "text": "<p>The main issue I was having is that when an ajax request hits not all hooks are being loaded. </p>\n\n<p>I...
2015/05/18
[ "https://wordpress.stackexchange.com/questions/188624", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73250/" ]
I am Using Wordpress for making a website and getting below Error only on my pages and No shortcodes are working due to this error. This error ONLY seen on PAGES they are working fine on POSTS. I don't know the solution of this error please help me out. I am new to wordpress. **Error:** WordPress database error: [You...
The main issue I was having is that when an ajax request hits not all hooks are being loaded. I used this code: ``` $return = array(); foreach( $GLOBALS['wp_actions'] as $action => $count ) { $return["message"] .= $action . ", "; } wp_send_json($return); ``` This showed me the hooks that were running before an...
188,631
<p>I am trying to upload image and the image should be inserted in a new post but I can't get the image displayed in the post editor even if the image is successfully uploaded. Here's my upload button:</p> <pre><code>&lt;input type="file" name="file" id="file"&gt; </code></pre> <p>This is the code I added in my php ...
[ { "answer_id": 203299, "author": "clap", "author_id": 65450, "author_profile": "https://wordpress.stackexchange.com/users/65450", "pm_score": 0, "selected": false, "text": "<p>Use this code it works fine for me</p>\n\n<pre><code>/*\n * Function to upload feature image for post on front e...
2015/05/18
[ "https://wordpress.stackexchange.com/questions/188631", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73248/" ]
I am trying to upload image and the image should be inserted in a new post but I can't get the image displayed in the post editor even if the image is successfully uploaded. Here's my upload button: ``` <input type="file" name="file" id="file"> ``` This is the code I added in my php action form: ``` $target = "/ww...
First, verify that the file has been uploaded successfully. The [`wp_handle_upload`](https://codex.wordpress.org/Function_Reference/wp_handle_upload) function is great for simple processing of the upload itself. Once it's uploaded, in order to attach the file to the ACF field, you'll need to [process it as a WordPress...
188,633
<p>I am using a theme <a href="http://www.vivathemes.com/indigo/" rel="nofollow">Indigo</a> and have it working fine, in a child theme configuration. I want to add a custom function. Unlike the child style.css, I have read that you don't need to import the parent functions.php. However when I add my own function to a b...
[ { "answer_id": 203299, "author": "clap", "author_id": 65450, "author_profile": "https://wordpress.stackexchange.com/users/65450", "pm_score": 0, "selected": false, "text": "<p>Use this code it works fine for me</p>\n\n<pre><code>/*\n * Function to upload feature image for post on front e...
2015/05/18
[ "https://wordpress.stackexchange.com/questions/188633", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70649/" ]
I am using a theme [Indigo](http://www.vivathemes.com/indigo/) and have it working fine, in a child theme configuration. I want to add a custom function. Unlike the child style.css, I have read that you don't need to import the parent functions.php. However when I add my own function to a blank file, functions.php in t...
First, verify that the file has been uploaded successfully. The [`wp_handle_upload`](https://codex.wordpress.org/Function_Reference/wp_handle_upload) function is great for simple processing of the upload itself. Once it's uploaded, in order to attach the file to the ACF field, you'll need to [process it as a WordPress...
188,648
<p>I am currently using a loop that goes trough all sidebars looking for widgets than loop those again in order to get all widgets options. </p> <p>Doing this on </p> <pre><code>add_filter('sidebars_widgets', array($this, 'sidebars_widgets')); </code></pre> <p>filter and it just does not seem right that I need to l...
[ { "answer_id": 188651, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 3, "selected": true, "text": "<p>This actually seems like a quite plausible approach - to me. </p>\n\n<p>There is nothing wrong with ...
2015/05/18
[ "https://wordpress.stackexchange.com/questions/188648", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67176/" ]
I am currently using a loop that goes trough all sidebars looking for widgets than loop those again in order to get all widgets options. Doing this on ``` add_filter('sidebars_widgets', array($this, 'sidebars_widgets')); ``` filter and it just does not seem right that I need to loop this much just to get all opti...
This actually seems like a quite plausible approach - to me. There is nothing wrong with looping through it, sometimes it is the only/fastest way anyway. I don't know how you get your sidebars, but for this ``` $sidebars_widgets = get_option( 'sidebars_widgets' ); ``` can be used. Which gives you an associative ...
188,653
<p>I would like to run a function when the user clicks the "Empty Trash" button for posts. Something like:</p> <pre><code>add_action('empty_trash','myFunction'); function myFunction(){ // My code } </code></pre>
[ { "answer_id": 188662, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 5, "selected": true, "text": "<p>I don't think there exist one, but you could create your own, <code>wpse_empty_trash</code>, with something l...
2015/05/18
[ "https://wordpress.stackexchange.com/questions/188653", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73266/" ]
I would like to run a function when the user clicks the "Empty Trash" button for posts. Something like: ``` add_action('empty_trash','myFunction'); function myFunction(){ // My code } ```
I don't think there exist one, but you could create your own, `wpse_empty_trash`, with something like this: ``` /** * Add a custom hook 'wpse_empty_trash' */ add_action( 'load-edit.php', function() { add_action( 'before_delete_post', function ( $post_id ) { if ( 'trash' === get_post_statu...
188,654
<p>On my website I use bootstrap which I've implemented in functions.php. Now I am trying to implement my stylesheet after bootstrap, so that I can override its classes.</p> <p>My stylesheet worksbut it's still overriden by bootstrap. Did I implement it wrong?</p> <p>functions.php:</p> <pre><code>&lt;?php add_action...
[ { "answer_id": 188656, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 1, "selected": true, "text": "<p>Note</p>\n\n<pre><code>wp_enqueue_style()\n</code></pre>\n\n<p>should be placed inside a callback fu...
2015/05/18
[ "https://wordpress.stackexchange.com/questions/188654", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70866/" ]
On my website I use bootstrap which I've implemented in functions.php. Now I am trying to implement my stylesheet after bootstrap, so that I can override its classes. My stylesheet worksbut it's still overriden by bootstrap. Did I implement it wrong? functions.php: ``` <?php add_action( 'after_setup_theme', 'wpt_set...
Note ``` wp_enqueue_style() ``` should be placed inside a callback function to `wp_enqueue_scripts` ``` add_action( 'wp_enqueue_scripts', 'callback' ); ``` Like your code in the question shows, so put your loading of the custom stylesheet with `wp_enqueue_style()` inside it. Last but not least, CSS is processed ...
188,669
<p>I've got a WooCommerce category for sold items within WooCommerce's custom post type of 'product'. What I'm trying to do is have the site search only return results from the product post type but also exclude the sold items category. Any code I seem to find to exclude categories from search doesn't seem to work but ...
[ { "answer_id": 188675, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 3, "selected": true, "text": "<p>The problem with your approach is that woocommerces product category is a custom taxonomy called <co...
2015/05/18
[ "https://wordpress.stackexchange.com/questions/188669", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36920/" ]
I've got a WooCommerce category for sold items within WooCommerce's custom post type of 'product'. What I'm trying to do is have the site search only return results from the product post type but also exclude the sold items category. Any code I seem to find to exclude categories from search doesn't seem to work but I'm...
The problem with your approach is that woocommerces product category is a custom taxonomy called `product_cat`. But with `cat` you are addressing the built-in category. Taxonomies can be addressed with a [tax query](https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters), simplified example below: ``...
188,679
<p>I want to add a filter ... but not if it that filter is called by a specific function. Here's a simplified example:</p> <pre><code>&lt;?php add_filter( 'get_the_excerpt', 'wp_trim_excerpt' ); function wp_trim_excerpt( $text ) { $text = apply_filters( 'the_content', $text ); return $text; } add_filter( ...
[ { "answer_id": 188683, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 1, "selected": false, "text": "<p>WordPress only holds the <code>hooks</code> information in global <code>$wp_filter</code> so you can check if a...
2015/05/18
[ "https://wordpress.stackexchange.com/questions/188679", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9058/" ]
I want to add a filter ... but not if it that filter is called by a specific function. Here's a simplified example: ``` <?php add_filter( 'get_the_excerpt', 'wp_trim_excerpt' ); function wp_trim_excerpt( $text ) { $text = apply_filters( 'the_content', $text ); return $text; } add_filter( 'the_content', 'm...
WordPress only holds the `hooks` information in global `$wp_filter` so you can check if a hook is registered with some specified function or not. you can also use function [has\_filter](https://codex.wordpress.org/Function_Reference/has_filter). But I guess you can not check that, it has been called or not on some spe...
188,702
<p>As you know, we can assign a "Category" to any post we write. We can also use a "Category" as link on the menu. Good!</p> <p>By default, WordPress will display all your posts in all the categories on your front page.</p> <p>However, how to prevent Wordpress displaying a "Category" type on the front page? Example, ...
[ { "answer_id": 188728, "author": "Touqeer Shafi", "author_id": 63430, "author_profile": "https://wordpress.stackexchange.com/users/63430", "pm_score": 1, "selected": false, "text": "<p>You can use <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=\"nof...
2015/05/18
[ "https://wordpress.stackexchange.com/questions/188702", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73291/" ]
As you know, we can assign a "Category" to any post we write. We can also use a "Category" as link on the menu. Good! By default, WordPress will display all your posts in all the categories on your front page. However, how to prevent Wordpress displaying a "Category" type on the front page? Example, I have a post wit...
You can use [pre\_get\_posts](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) > > Exclude categories on your main page > > > ``` function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '-1,-1347' ); } } add_action( 'pre...
188,706
<p>OK, I have looked and read quite a few message boards about this problem and I can not seem to find an answer. </p> <p>I am uploading thousands of photos for a photographer and using the WP Gallery shortcode. I do not want to manually input captions for every thumbnail, I want the image title to automatically pop...
[ { "answer_id": 188708, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>The quick &amp; dirty way, to set the title as caption, would be to use SQL (untested):</p>\n\n<pre><code>UPDA...
2015/05/18
[ "https://wordpress.stackexchange.com/questions/188706", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73294/" ]
OK, I have looked and read quite a few message boards about this problem and I can not seem to find an answer. I am uploading thousands of photos for a photographer and using the WP Gallery shortcode. I do not want to manually input captions for every thumbnail, I want the image title to automatically populate that a...
The quick & dirty way, to set the title as caption, would be to use SQL (untested): ``` UPDATE wp_posts SET post_excerpt = post_title WHERE post_excerpt = '' AND post_type = 'attachment' AND post_status = 'inherit' AND post_mime_type = 'image/jpeg' AND ID = 123 ...
188,719
<p>I have a (<a href="https://roots.io/sage/" rel="nofollow">Roots/Sage-based</a>) theme with a <code>home.php</code> template override and on that page am displaying excerpts and featured image for each post.</p> <pre><code>&lt;?php while (have_posts()) : the_post(); ?&gt; &lt;div class=".container-fluid"&gt; ...
[ { "answer_id": 188726, "author": "Tarei SuperChur King", "author_id": 41448, "author_profile": "https://wordpress.stackexchange.com/users/41448", "pm_score": 1, "selected": false, "text": "<p>As Nilambar mentioned, the correct function is <code>&lt;?php the_permalink(); ?&gt;</code>. </p...
2015/05/19
[ "https://wordpress.stackexchange.com/questions/188719", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48604/" ]
I have a ([Roots/Sage-based](https://roots.io/sage/)) theme with a `home.php` template override and on that page am displaying excerpts and featured image for each post. ``` <?php while (have_posts()) : the_post(); ?> <div class=".container-fluid"> <?php if (get_post_type() == 'instruments') {?> <div class...
As suggested, went to the [function reference](https://codex.wordpress.org/Function_Reference/the_permalink) and from there to the [Source File](https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/link-template.php) (located in `wp_includes/link-template.php`) in which there are four functions that each ...
188,725
<p>I have a global element as part of my theme and I need to reference and image as a background image. I need the URL to the image. I assume that it's bad practice to hard-code the URL and that the URL needs to be relative to the theme location. What is the recommended way of referencing an image within a stylesheet?<...
[ { "answer_id": 188727, "author": "m4n0", "author_id": 70936, "author_profile": "https://wordpress.stackexchange.com/users/70936", "pm_score": 5, "selected": true, "text": "<p>It depends on your image and stylesheet location.</p>\n\n<p>But this is the syntax:</p>\n\n<pre><code>.theme-imag...
2015/05/19
[ "https://wordpress.stackexchange.com/questions/188725", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60152/" ]
I have a global element as part of my theme and I need to reference and image as a background image. I need the URL to the image. I assume that it's bad practice to hard-code the URL and that the URL needs to be relative to the theme location. What is the recommended way of referencing an image within a stylesheet?
It depends on your image and stylesheet location. But this is the syntax: ``` .theme-image { background-image: url('../images/header-img.jpg'); } ``` The above code is for the structure ``` wp-content - themes - your-theme - images - header-img.jpg - css - style.css ``` You are making the...
188,743
<p><img src="https://i.stack.imgur.com/2f8sl.jpg" alt="enter image description here"></p> <p>Image should explain what I am trying to accomplish. I have no idea how to do this, is anyone familiar with this sort of work?</p> <p>Custom event date will be a custom event meta box value that is part of the post type. I wa...
[ { "answer_id": 188780, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 2, "selected": true, "text": "<p>There is the hook <a href=\"https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_$post_typ...
2015/05/19
[ "https://wordpress.stackexchange.com/questions/188743", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73300/" ]
![enter image description here](https://i.stack.imgur.com/2f8sl.jpg) Image should explain what I am trying to accomplish. I have no idea how to do this, is anyone familiar with this sort of work? Custom event date will be a custom event meta box value that is part of the post type. I want the custom meta box to have ...
There is the hook [`manage_${post_type}_posts_columns`](https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_$post_type_posts_columns) which can be used to do just that. Basic example: ``` function wpse188743_events_cpt_columns( $columns ) { $new_columns = array( 'event_date' => __( 'Event Date'...
188,746
<p>I need to add "item/" prefix to post url only</p> <p>I went to Settings -> Permalinks and set this :</p> <pre><code>/item/%postname%/ </code></pre> <p>and for category and tag set this:</p> <pre><code>category tag </code></pre> <p>But other post_type and taxonomies and author has "item/" prefix</p> <p>I try c...
[ { "answer_id": 202461, "author": "aesede", "author_id": 51847, "author_profile": "https://wordpress.stackexchange.com/users/51847", "pm_score": 0, "selected": false, "text": "<p>I think this is answered here: <a href=\"https://wordpress.stackexchange.com/a/63895/51847\">https://wordpress...
2015/05/19
[ "https://wordpress.stackexchange.com/questions/188746", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73311/" ]
I need to add "item/" prefix to post url only I went to Settings -> Permalinks and set this : ``` /item/%postname%/ ``` and for category and tag set this: ``` category tag ``` But other post\_type and taxonomies and author has "item/" prefix I try correct author URL with this code: ``` add_action('init', 'ztco...
You have to set `with_front` to `false` when you register your taxonomy or post type to not have the prefix included in the URLs.
188,749
<p>I am trying to add URL parameter to all the URLs of Wordpress website. </p> <p>This is for tracking affiliate sales by tracking links. </p> <p>E.g. I have put a link on another website </p> <pre><code>http://website.com/?aff=abc </code></pre> <p>When a person comes to my website via that link the parameter sta...
[ { "answer_id": 188757, "author": "Chris Vogt", "author_id": 35144, "author_profile": "https://wordpress.stackexchange.com/users/35144", "pm_score": 0, "selected": false, "text": "<p>Look into using <code>add_query_arg()</code> (<a href=\"https://developer.wordpress.org/reference/function...
2015/05/19
[ "https://wordpress.stackexchange.com/questions/188749", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73314/" ]
I am trying to add URL parameter to all the URLs of Wordpress website. This is for tracking affiliate sales by tracking links. E.g. I have put a link on another website ``` http://website.com/?aff=abc ``` When a person comes to my website via that link the parameter stays in the URL but as soon as the person go...
I don't know if you still need the answer, but here's working example for you. Header.php ``` /*SAVE $_GET['aff'] TO COOKIE*/ if(!isset($_SESSION['aff']) and $_GET['aff']){ $cookie_expire = time()+60*60*24*30; $_SESSION['aff'] = $_GET['aff']; setcookie('aff', $_SESSION['aff'], $cookie_expire, '/', '.'.$_S...
188,769
<p>This is general question but lets say I have a function and on a specific page I want to display a table.</p> <p>The function only applies to one page on my site but every post/page will run this function (and skip it when it 'realises' it isn't the right page).</p> <p><strong>Would it be better</strong>, from a p...
[ { "answer_id": 188771, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 2, "selected": false, "text": "<p>A page template might be more efficient. </p>\n\n<p>If you decide to use the filter, you should return the va...
2015/05/19
[ "https://wordpress.stackexchange.com/questions/188769", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22502/" ]
This is general question but lets say I have a function and on a specific page I want to display a table. The function only applies to one page on my site but every post/page will run this function (and skip it when it 'realises' it isn't the right page). **Would it be better**, from a performance point of view, **to...
The difference would be negligible. The `the_content` filter is fired regardless of whether you use it or not because WordPress uses it for other things. So the only thing that would be performance related would be the complexity of your filter function. But since you'd probably be doing the same level of complexity ...
188,813
<p>I am trying to display content in a custom template based on referral URL. I put a link in my footer called <a href="http://domain.com/?ref=special" rel="nofollow">http://domain.com/?ref=special</a> and image2.gif shows still when I click it and go to the page. I need image1.gif to show if there is traffic coming...
[ { "answer_id": 188771, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 2, "selected": false, "text": "<p>A page template might be more efficient. </p>\n\n<p>If you decide to use the filter, you should return the va...
2015/05/19
[ "https://wordpress.stackexchange.com/questions/188813", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49017/" ]
I am trying to display content in a custom template based on referral URL. I put a link in my footer called <http://domain.com/?ref=special> and image2.gif shows still when I click it and go to the page. I need image1.gif to show if there is traffic coming from a domain that ends with ?ref=special. How can I do this an...
The difference would be negligible. The `the_content` filter is fired regardless of whether you use it or not because WordPress uses it for other things. So the only thing that would be performance related would be the complexity of your filter function. But since you'd probably be doing the same level of complexity ...
188,822
<p>I have already seen a similar post here: <a href="https://wordpress.stackexchange.com/questions/168584/how-to-get-the-number-of-times-an-audio-file-has-been-played">How to get the number of times an audio file has been played</a></p> <p>But the code provided by @bonger did not work for me. I uploaded the new funct...
[ { "answer_id": 189251, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 0, "selected": false, "text": "<p>The code requires at least PHP 5.3. Dreamweaver <a href=\"https://stackoverflow.com/questions/20224374/dreamweaver-cs...
2015/05/19
[ "https://wordpress.stackexchange.com/questions/188822", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19766/" ]
I have already seen a similar post here: [How to get the number of times an audio file has been played](https://wordpress.stackexchange.com/questions/168584/how-to-get-the-number-of-times-an-audio-file-has-been-played) But the code provided by @bonger did not work for me. I uploaded the new functions.php with the foll...
The code requires at least PHP 5.3. Dreamweaver [does not support that PHP version](https://stackoverflow.com/questions/20224374/dreamweaver-cs5-code-hinting-and-syntax-errors-with-php-5-4), so it reports unknown, newer syntax as errors. WordPress [requires just version 5.2.4, but it recommends at least 5.4](https://w...
188,846
<p>Initially I thought I'd use <code>get_users()</code> but it turned out it doesn't support the display_name field. Then I've read about using WP_User_Query, but when I do it always exhausts the allowed memory size of 134217728 bytes. When I remove the memory limit this part of the page doesn't even try to load. Now I...
[ { "answer_id": 188868, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>I think you should use the default class for this job - <a href=\"http://codex.wordpress.org/Class_Reference/WP_U...
2015/05/20
[ "https://wordpress.stackexchange.com/questions/188846", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71594/" ]
Initially I thought I'd use `get_users()` but it turned out it doesn't support the display\_name field. Then I've read about using WP\_User\_Query, but when I do it always exhausts the allowed memory size of 134217728 bytes. When I remove the memory limit this part of the page doesn't even try to load. Now I'm thinking...
I think you should use the default class for this job - [`WP_User_Query`](http://codex.wordpress.org/Class_Reference/WP_User_Query). The query have a lot of possibilities, also get the display name. WP\_User\_Query is a class that allows querying WordPress database tables `_users` and `_usermeta`. Also it is helpful w...
188,853
<p>How do I split the values within a custom post type loop so that the title is in the first loop which outputs in the first DIV and the content is in the second loop outputting in the second DIV? Two loops may not be the best way to do, I don't know. Somebody mentioned to me about using one loop then storing each ite...
[ { "answer_id": 188868, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>I think you should use the default class for this job - <a href=\"http://codex.wordpress.org/Class_Reference/WP_U...
2015/05/20
[ "https://wordpress.stackexchange.com/questions/188853", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63480/" ]
How do I split the values within a custom post type loop so that the title is in the first loop which outputs in the first DIV and the content is in the second loop outputting in the second DIV? Two loops may not be the best way to do, I don't know. Somebody mentioned to me about using one loop then storing each item i...
I think you should use the default class for this job - [`WP_User_Query`](http://codex.wordpress.org/Class_Reference/WP_User_Query). The query have a lot of possibilities, also get the display name. WP\_User\_Query is a class that allows querying WordPress database tables `_users` and `_usermeta`. Also it is helpful w...
188,859
<p>In permalinks(dashboard) section index.php added. e.g. </p> <p>Current Post Name: <a href="http://zakatchicago.com/index.php/sample-post/" rel="noreferrer">http://zakatchicago.com/index.php/sample-post/</a><br> Expected Post Name: <a href="http://zakatchicago.com/sample-post/" rel="noreferrer">http://zakatchicago.c...
[ { "answer_id": 188868, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>I think you should use the default class for this job - <a href=\"http://codex.wordpress.org/Class_Reference/WP_U...
2015/05/20
[ "https://wordpress.stackexchange.com/questions/188859", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73374/" ]
In permalinks(dashboard) section index.php added. e.g. Current Post Name: <http://zakatchicago.com/index.php/sample-post/> Expected Post Name: <http://zakatchicago.com/sample-post/> How can i remove index.php? **Note: I am using windows server**
I think you should use the default class for this job - [`WP_User_Query`](http://codex.wordpress.org/Class_Reference/WP_User_Query). The query have a lot of possibilities, also get the display name. WP\_User\_Query is a class that allows querying WordPress database tables `_users` and `_usermeta`. Also it is helpful w...
188,863
<p>I have three extra roles in my site.</p> <ol> <li>Doctor</li> <li>Receptionist</li> <li>Guest</li> </ol> <p>those roles are added by following code:</p> <pre><code>* adding Doctor role */ $doctor_role = add_role('Doctor', __('Doctor'), array('read'=&gt;'true')); /* adding Receptionist role */ $receptionist_role ...
[ { "answer_id": 188889, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 6, "selected": true, "text": "<p>Firstly, you need to add the following capabilities to the <code>Doctor</code> and <code>Receptionist</code...
2015/05/20
[ "https://wordpress.stackexchange.com/questions/188863", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43764/" ]
I have three extra roles in my site. 1. Doctor 2. Receptionist 3. Guest those roles are added by following code: ``` * adding Doctor role */ $doctor_role = add_role('Doctor', __('Doctor'), array('read'=>'true')); /* adding Receptionist role */ $receptionist_role = add_role('Receptionist', __('Receptionist'), array(...
Firstly, you need to add the following capabilities to the `Doctor` and `Receptionist` role: * `list_users` * `edit_users` * `create_users` * `delete_users` Now we can get to work with controlling *which* users they can create/edite/delete. Let's start with a "helper" function that will return which roles a user is a...
188,872
<p>I'm working on my own wordpress theme for the first time. I registered a new post type with custom taxonomy, but I can't display the posts by terms. I duplicated the archive.php and renamed it to taxonomy-[mycustomtaxonomy].php and modified few lines.</p> <p>I left the loops as it exists in the archive.php:</p> <p...
[ { "answer_id": 188889, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 6, "selected": true, "text": "<p>Firstly, you need to add the following capabilities to the <code>Doctor</code> and <code>Receptionist</code...
2015/05/20
[ "https://wordpress.stackexchange.com/questions/188872", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38284/" ]
I'm working on my own wordpress theme for the first time. I registered a new post type with custom taxonomy, but I can't display the posts by terms. I duplicated the archive.php and renamed it to taxonomy-[mycustomtaxonomy].php and modified few lines. I left the loops as it exists in the archive.php: ``` <?php if ( h...
Firstly, you need to add the following capabilities to the `Doctor` and `Receptionist` role: * `list_users` * `edit_users` * `create_users` * `delete_users` Now we can get to work with controlling *which* users they can create/edite/delete. Let's start with a "helper" function that will return which roles a user is a...
188,881
<p>I have developed responsive theme and I want to submit it the <b>wordpress.org</b>. Before submitting it I want to use <code>wp_is_mobile()</code> in my theme, but according to <a href="https://codex.wordpress.org/Function_Reference/wp_is_mobile"> Function Reference/wp is mobile</a> it is a <b>bad idea</b> because i...
[ { "answer_id": 188897, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 6, "selected": true, "text": "<p>In very layman term <code>wp_is_mobile()</code> is not for styling your theme.</p>\n\n<p><strong>How it works:</...
2015/05/20
[ "https://wordpress.stackexchange.com/questions/188881", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20941/" ]
I have developed responsive theme and I want to submit it the **wordpress.org**. Before submitting it I want to use `wp_is_mobile()` in my theme, but according to [Function Reference/wp is mobile](https://codex.wordpress.org/Function_Reference/wp_is_mobile) it is a **bad idea** because it say's this : You should real...
In very layman term `wp_is_mobile()` is not for styling your theme. **How it works:** It matches some of device's native name in User Agent String. So if someone manipulate the string and send false information you can not detect what device it is. And it does not return any device name it just return `true` if you ar...
188,892
<p>This is how I am currently trying:</p> <pre><code>$taxonomies = array( 'product_cat' ); $args = array( 'orderby' =&gt; 'name', 'order' =&gt; 'ASC', 'hide_empty' =&gt; false, 'exclude' =&gt; array(), 'exclude_tree' =&gt; array(), 'include' ...
[ { "answer_id": 188896, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Taxonomies don't by default have thumbnail images. Without knowing how those are set I can't say exactly how...
2015/05/20
[ "https://wordpress.stackexchange.com/questions/188892", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3435/" ]
This is how I am currently trying: ``` $taxonomies = array( 'product_cat' ); $args = array( 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(), 'number' ...
The images where setted by woocommerce, In case someone needs, this is how I did it (in 2015) ``` $thumb_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ); $term_img = wp_get_attachment_url( $thumb_id ); ```
188,908
<p>I read many Q&amp;As here on SO...(and elsewhere but they don't count...lol)<br /> I think I follow the rules of WP.org but still it does not load the scripts.</p> <p>Scenario: Custom template for post in Php:</p> <pre><code>&lt;?php /* * Template Name: YYY * Description: Form for YYY donation. * NO FOOTER */...
[ { "answer_id": 188896, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Taxonomies don't by default have thumbnail images. Without knowing how those are set I can't say exactly how...
2015/05/20
[ "https://wordpress.stackexchange.com/questions/188908", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/52581/" ]
I read many Q&As here on SO...(and elsewhere but they don't count...lol) I think I follow the rules of WP.org but still it does not load the scripts. Scenario: Custom template for post in Php: ``` <?php /* * Template Name: YYY * Description: Form for YYY donation. * NO FOOTER */ get_header(); ?> <div id="cont...
The images where setted by woocommerce, In case someone needs, this is how I did it (in 2015) ``` $thumb_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ); $term_img = wp_get_attachment_url( $thumb_id ); ```
188,941
<p>i am trying to upload image it is uploaded successfully but when i tried to access it in phpmysql the link is somethig like this : <a href="http://localhost/job/?attachment_id=40" rel="nofollow">http://localhost/job/?attachment_id=40</a></p> <p>i want to store this image url like this: <a href="http://localhost/job...
[ { "answer_id": 188896, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Taxonomies don't by default have thumbnail images. Without knowing how those are set I can't say exactly how...
2015/05/21
[ "https://wordpress.stackexchange.com/questions/188941", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73412/" ]
i am trying to upload image it is uploaded successfully but when i tried to access it in phpmysql the link is somethig like this : <http://localhost/job/?attachment_id=40> i want to store this image url like this: <http://localhost/job/wp-content/uploads/2015/05/Koala.jpg> here is code to upload image: ``` if(!empty...
The images where setted by woocommerce, In case someone needs, this is how I did it (in 2015) ``` $thumb_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ); $term_img = wp_get_attachment_url( $thumb_id ); ```
188,942
<p>I have noticed that some plugins such as <a href="https://wordpress.org/support/topic/plugin-contact-form-7-using-shortcode-in-admin-section?replies=3" rel="nofollow">Contact-form-7</a>, <a href="https://wordpress.org/support/topic/no-longer-possible-to-get-nggallery-content-from-admin-ajax-context?replies=5" rel="n...
[ { "answer_id": 189214, "author": "Philipp", "author_id": 31140, "author_profile": "https://wordpress.stackexchange.com/users/31140", "pm_score": 4, "selected": true, "text": "<p>I have observed the same issue with contact-form-7 a while back.</p>\n\n<p>But note that registering shortcode...
2015/05/21
[ "https://wordpress.stackexchange.com/questions/188942", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25767/" ]
I have noticed that some plugins such as [Contact-form-7](https://wordpress.org/support/topic/plugin-contact-form-7-using-shortcode-in-admin-section?replies=3), [Nextgen-gallery](https://wordpress.org/support/topic/no-longer-possible-to-get-nggallery-content-from-admin-ajax-context?replies=5), possibly others, have an ...
I have observed the same issue with contact-form-7 a while back. But note that registering shortcodes based on `is_admin` is *doing\_it\_wrong* ([see gmazzap`s answer](https://wordpress.stackexchange.com/a/189254/31140)) There are the two reasons that *seem* legitimate at first sight (and why they are wrong): 1. (Un...
188,956
<p>i want from my footer.php file some part like <code>&lt;div class="form"&gt;----------&lt;/div&gt;</code> this part will be visible all page but not show in home page and few other other. i think it is possible via use php condition.</p> <p>i read <a href="https://wordpress.stackexchange.com/questions/99699/is-home...
[ { "answer_id": 188958, "author": "Vee", "author_id": 44979, "author_profile": "https://wordpress.stackexchange.com/users/44979", "pm_score": 0, "selected": false, "text": "<p>Use this.</p>\n\n<pre><code>&lt;?php \nif ( (!is_front_page() ) &amp;&amp; (is_page (14) || is_page(25) || .... )...
2015/05/21
[ "https://wordpress.stackexchange.com/questions/188956", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68799/" ]
i want from my footer.php file some part like `<div class="form">----------</div>` this part will be visible all page but not show in home page and few other other. i think it is possible via use php condition. i read [is\_home, and is\_front\_page conditional problem](https://wordpress.stackexchange.com/questions/996...
You want to "reverse" your logic, in a sense. You need "not (home or front)", not "not home and not front". For example: ``` // var_dump(is_home(),is_front_page(),(is_home() || is_front_page()),!(is_home() || is_front_page())); // debug if ( !(is_home() || is_front_page()) ) { echo "Hello World"; } else { echo "El...
188,979
<p>I am developing a plugin in which I want to open media library box after clicking on a link from Admin Panel just like we do for Choose featured image.</p> <pre><code>&lt;a href="#"&gt;Choose Image&lt;/a&gt; </code></pre> <p>After clicking on Choose Image I want that media library box displayed in thickbox.</p> <...
[ { "answer_id": 188991, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": 2, "selected": true, "text": "<p>By enququing an JS file we can do like this:</p>\n\n<pre><code>&lt;img src=\"#\" id=\"img-src\"&gt;\n&lt;a href=...
2015/05/21
[ "https://wordpress.stackexchange.com/questions/188979", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64614/" ]
I am developing a plugin in which I want to open media library box after clicking on a link from Admin Panel just like we do for Choose featured image. ``` <a href="#">Choose Image</a> ``` After clicking on Choose Image I want that media library box displayed in thickbox. Thanks
By enququing an JS file we can do like this: ``` <img src="#" id="img-src"> <a href="#" id="img-upload">Add Image</a> ``` **Content of JS file** ``` jQuery(document).ready(function(e){ e.preventDefault(); jQeury('#img-upload').click(function(){ var upload = wp.media({ title:'Choose Image', /...
188,993
<p>I have a meta key called <code>$availability</code> that can have one of four options but also multiple values separated by pipe: <code>|</code>.</p> <p>For example the value could be: <code>severaltimes_week|oncetwice_month|occasionally</code>.</p> <p>I haven't found the right comparison operator for this issue, ...
[ { "answer_id": 188991, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": 2, "selected": true, "text": "<p>By enququing an JS file we can do like this:</p>\n\n<pre><code>&lt;img src=\"#\" id=\"img-src\"&gt;\n&lt;a href=...
2015/05/21
[ "https://wordpress.stackexchange.com/questions/188993", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73437/" ]
I have a meta key called `$availability` that can have one of four options but also multiple values separated by pipe: `|`. For example the value could be: `severaltimes_week|oncetwice_month|occasionally`. I haven't found the right comparison operator for this issue, which one will work best? ``` if ( $_GET['ava1'] ...
By enququing an JS file we can do like this: ``` <img src="#" id="img-src"> <a href="#" id="img-upload">Add Image</a> ``` **Content of JS file** ``` jQuery(document).ready(function(e){ e.preventDefault(); jQeury('#img-upload').click(function(){ var upload = wp.media({ title:'Choose Image', /...
189,001
<p>I would like to simply create an url rewrite that takes the third argument and matches it to its corresponding pages, ignoring the other two arguments.</p> <pre><code>domain.com/argument1/argument2/page-slug = 'index.php?page_id=XXX'; </code></pre> <p>Is it possible to call a page via it's slug instead of it's ID,...
[ { "answer_id": 189003, "author": "Dillonsmart", "author_id": 67253, "author_profile": "https://wordpress.stackexchange.com/users/67253", "pm_score": 0, "selected": false, "text": "<p>You can try selecting the <code>$post_id</code> where <code>$page_name = $page_name</code> </p>\n" }, ...
2015/05/21
[ "https://wordpress.stackexchange.com/questions/189001", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56526/" ]
I would like to simply create an url rewrite that takes the third argument and matches it to its corresponding pages, ignoring the other two arguments. ``` domain.com/argument1/argument2/page-slug = 'index.php?page_id=XXX'; ``` Is it possible to call a page via it's slug instead of it's ID, or can I somehow generate...
Use `pagename` instead of `page_id` to query by slug. Note that if a page is a child of another page, `pagename` has to be the full parent/child path to the page, since slugs only have to be unique per-level in hierarchical post types. See [`WP_Query`](https://codex.wordpress.org/Class_Reference/WP_Query) for the full ...
189,006
<h1>EDIT</h1> <p>It turns out that I was barking up the wrong tree trying to edit .htaccess, as nginx doesn't use it. What I apparently need to do is edit my .conf file. Before I read this, my_app.conf looked like this:</p> <pre><code>upstream backend { server unix:/u/apps/my_app/tmp/php.sock; } server { list...
[ { "answer_id": 189007, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 5, "selected": true, "text": "<p>Those are Apache <code>.htaccess</code> rewrite rules, but you have stated that you are on an Nginx server. N...
2015/05/21
[ "https://wordpress.stackexchange.com/questions/189006", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37909/" ]
EDIT ==== It turns out that I was barking up the wrong tree trying to edit .htaccess, as nginx doesn't use it. What I apparently need to do is edit my .conf file. Before I read this, my\_app.conf looked like this: ``` upstream backend { server unix:/u/apps/my_app/tmp/php.sock; } server { listen 80 default; ...
Those are Apache `.htaccess` rewrite rules, but you have stated that you are on an Nginx server. Nginx does not use an `.htaccess`-like directory level file, much less does it use the `.htaccess` file itself.. You need to edit the server configuration itself. [The Codex has a detail sample](http://codex.wordpress.org/N...
189,024
<p>I'm trying to add a related posts section to the bottom of my single post views. It needs to grab the categories of the current post and show just 2 posts that match any of those categories. I'm almost there, but my results are showing 2 from each category as opposed to a total of 2. </p> ...
[ { "answer_id": 189031, "author": "shanebp", "author_id": 16575, "author_profile": "https://wordpress.stackexchange.com/users/16575", "pm_score": 0, "selected": false, "text": "<p><code>$i</code> is being reset for each category.</p>\n\n<p>Try declaring $i before the foreach cat loop:</p>...
2015/05/21
[ "https://wordpress.stackexchange.com/questions/189024", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57514/" ]
I'm trying to add a related posts section to the bottom of my single post views. It needs to grab the categories of the current post and show just 2 posts that match any of those categories. I'm almost there, but my results are showing 2 from each category as opposed to a total of 2. ``` <?php if ( is_single() ) { ?>...
Build an array of categories: ``` foreach ($categories as $category) { $cat[] = $category->cat_ID; } ``` Then pass that to the query: ``` $args=array( 'category__in' => $cat, 'order' =>DESC, 'post__not_in' => array($post->ID), 'posts_per_page'=>2, ); ``` In other words, put the query after the `for...
189,035
<p>I have a father blog / main blog inside a multisite that has a specific taxonomy with 20+ terms inside it. i just need a list of all the terms inside that taxonomy... </p> <p>i dont mind quering using WPDB but just dont know to how to write it correctly or in any other way i tried use: "<strong>switch_to_blog</st...
[ { "answer_id": 190851, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 4, "selected": true, "text": "<p>No way to do that in a \"word press\" way...</p>\n\n<pre><code>function multisite_profession_select(){\n ...
2015/05/21
[ "https://wordpress.stackexchange.com/questions/189035", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7990/" ]
I have a father blog / main blog inside a multisite that has a specific taxonomy with 20+ terms inside it. i just need a list of all the terms inside that taxonomy... i dont mind quering using WPDB but just dont know to how to write it correctly or in any other way i tried use: "**switch\_to\_blog**" but that doesnt ...
No way to do that in a "word press" way... ``` function multisite_profession_select(){ switch_to_blog(1); $taxonomies = array('rsitecat'); $check_later = array(); global $wp_taxonomies; foreach($taxonomies as $taxonomy){ if (isset($wp_taxonomies[$taxonomy])){ $check_later[$taxo...
189,055
<p>So I have a custom query, in which I'm displaying some results posts of a custom post type called "staff". This custom post type is linked to a custom taxonomy called "department". I am able to display results, but I am unable to print the category that's linked to each post.</p> <p>This is my code:</p> <pre><code...
[ { "answer_id": 189057, "author": "Johann", "author_id": 21245, "author_profile": "https://wordpress.stackexchange.com/users/21245", "pm_score": 5, "selected": true, "text": "<p>So this is what I needed:</p>\n\n<pre><code>&lt;?php\n$terms = get_the_terms( $post-&gt;ID , 'board' );\nforeac...
2015/05/22
[ "https://wordpress.stackexchange.com/questions/189055", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21245/" ]
So I have a custom query, in which I'm displaying some results posts of a custom post type called "staff". This custom post type is linked to a custom taxonomy called "department". I am able to display results, but I am unable to print the category that's linked to each post. This is my code: ``` <?php ...
So this is what I needed: ``` <?php $terms = get_the_terms( $post->ID , 'board' ); foreach ( $terms as $term ) { echo $term->name; } ?> ```
189,059
<p>I have two users with the capability to create other users. But their roles are not same. </p> <ol> <li>Tom - Role is Administrator</li> <li>Jackie - Role is CMS Manger (a custom created role)</li> </ol> <p>Both have capability to create new users. <code>CMS Manger</code> gets this capability by following cod...
[ { "answer_id": 189065, "author": "Riffaz Starr", "author_id": 43764, "author_profile": "https://wordpress.stackexchange.com/users/43764", "pm_score": 3, "selected": true, "text": "<p>I've found it.</p>\n\n<pre><code>/*** Adding extra field to get the the user who creates the another user...
2015/05/22
[ "https://wordpress.stackexchange.com/questions/189059", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43764/" ]
I have two users with the capability to create other users. But their roles are not same. 1. Tom - Role is Administrator 2. Jackie - Role is CMS Manger (a custom created role) Both have capability to create new users. `CMS Manger` gets this capability by following code: ``` add_action( 'after_setup_theme', 'add_cap...
I've found it. ``` /*** Adding extra field to get the the user who creates the another user during ADD NEW USER ***/ function custom_user_profile_fields($user){ if(is_object($user)) $created_by = esc_attr( get_the_author_meta( 'created_by', $user->ID ) ); else $created_by = null; ?> <h3...
189,062
<p>I'm creating a child theme from Storefront.</p> <p>Now I want to remove these action in child theme</p> <pre><code>add_action( 'woocommerce_before_shop_loop','storefront_sorting_wrapper',9 ); </code></pre> <p>by this function:</p> <pre><code>add_action( 'after_setup_theme','remove_action', 100 ); function remo...
[ { "answer_id": 189066, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 6, "selected": true, "text": "<p>For removing an action hook you should use the same action name, callback name and the priority that was used to...
2015/05/22
[ "https://wordpress.stackexchange.com/questions/189062", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54976/" ]
I'm creating a child theme from Storefront. Now I want to remove these action in child theme ``` add_action( 'woocommerce_before_shop_loop','storefront_sorting_wrapper',9 ); ``` by this function: ``` add_action( 'after_setup_theme','remove_action', 100 ); function remove_action() { remove_action( 'init', 'wo...
For removing an action hook you should use the same action name, callback name and the priority that was used to add a action in parent theme. And register it on `init` ``` add_action( 'init', 'remove_my_action'); function remove_my_action() { remove_action( 'woocommerce_before_shop_loop','storefront_sorting_wr...
189,084
<p>I am working on a plugin in plugin. I make template folder and in template folder and there are files of plugin that shows my post type data.</p> <p><strong>First Scenario</strong></p> <p>When user activate my plugin the template folder move to active theme folder. Its working perfectly.</p> <p><strong>Second Sce...
[ { "answer_id": 189088, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": false, "text": "<p>You could try the following:</p>\n\n<pre><code>add_action( 'switch_theme', function( $new_name, $new_theme )\...
2015/05/22
[ "https://wordpress.stackexchange.com/questions/189084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64316/" ]
I am working on a plugin in plugin. I make template folder and in template folder and there are files of plugin that shows my post type data. **First Scenario** When user activate my plugin the template folder move to active theme folder. Its working perfectly. **Second Scenario** Now If there is parent and child t...
I try this code and it solve my problem ``` if ( is_child_theme() === false ) { // files moved } else { // do nothing } ``` Thankx to @birgire
189,094
<p>I just cannot figure out what is calling two jquery scripts in my theme. Even if I <strong>turn off all plugins</strong>, they're still being called. I have <strong>not enqueued</strong> them in my <strong>function.php</strong> and also not in my <strong>header.php</strong> or <strong>footer.php</strong>.</p> <p>Cou...
[ { "answer_id": 189096, "author": "Nauman", "author_id": 65178, "author_profile": "https://wordpress.stackexchange.com/users/65178", "pm_score": -1, "selected": false, "text": "<p>jQuery is a part of wordpress core. Its added and included by default. Latest version of Wordpress uses the l...
2015/05/22
[ "https://wordpress.stackexchange.com/questions/189094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6903/" ]
I just cannot figure out what is calling two jquery scripts in my theme. Even if I **turn off all plugins**, they're still being called. I have **not enqueued** them in my **function.php** and also not in my **header.php** or **footer.php**. Could it be that the WP core is calling them? Is there any way to find out? ...
If I am correct, those two js files are "only" loaded by WP itself for use in the back-end(Admin), but not *(and WP would not load them if no need for it)* in the front-end. As soon a plugin needs them, they will be loaded *(e.g. through a function)* in the front-end. *(which seems not in your case because you sa...
189,121
<p>I have some danish users that uses special chars like æøå and they can't log in to my wordpress blog. I tried on a fresh install on 4.2.2 and on 4.1.5 and it did not work, for example Andrew Schønnemann with a simple password and it did not work, got message <code>ERROR: Invalid username. Lost your password?</code>....
[ { "answer_id": 189122, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Are you creating your users via regular means or somehow importing them?</p>\n\n<p>Trying to create such user WP pr...
2015/05/22
[ "https://wordpress.stackexchange.com/questions/189121", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133527/" ]
I have some danish users that uses special chars like æøå and they can't log in to my wordpress blog. I tried on a fresh install on 4.2.2 and on 4.1.5 and it did not work, for example Andrew Schønnemann with a simple password and it did not work, got message `ERROR: Invalid username. Lost your password?`. But with user...
Found the answer, created the following function: ``` function wscu_sanitize_user ($username, $raw_username, $strict) { $username = wp_strip_all_tags ($raw_username); return $username; } add_filter ('sanitize_user', 'wscu_sanitize_user', 10, 3); ```
189,138
<p>Hi I use a loop like this:</p> <pre><code>// show all active coupons for this store and setup pagination $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post_type' =&gt; APP_POST_TYPE, 'post_status' =&gt; 'publish', APP_TAX_STORE =&gt; $term-&gt;slug, 'ignore_sti...
[ { "answer_id": 189139, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 1, "selected": false, "text": "<p>Do <strong>NOT</strong> use <code>query_posts()</code> - it is <strong>bad</strong>, very bad to be...
2015/05/22
[ "https://wordpress.stackexchange.com/questions/189138", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73504/" ]
Hi I use a loop like this: ``` // show all active coupons for this store and setup pagination $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => APP_POST_TYPE, 'post_status' => 'publish', APP_TAX_STORE => $term->slug, 'ignore_sticky_posts' => 1, 'post...
Do **NOT** use `query_posts()` - it is **bad**, very bad to be exact. For more information read: * [When should you use WP\_Query vs query\_posts() vs get\_posts()?](https://wordpress.stackexchange.com/q/1753/22534) * [When to use WP\_query(), query\_posts() and pre\_get\_posts](https://wordpress.stackexchange.com/q...
189,148
<p>I'm familiar with <a href="https://wordpress.stackexchange.com/questions/17885/set-custom-messages-for-post-update-save">how to set custom messages for post updates</a> using the <code>post_updated_messages</code> action hook. This question is slightly different.</p> <p>I have a function/action hook on <code>post_u...
[ { "answer_id": 189139, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 1, "selected": false, "text": "<p>Do <strong>NOT</strong> use <code>query_posts()</code> - it is <strong>bad</strong>, very bad to be...
2015/05/22
[ "https://wordpress.stackexchange.com/questions/189148", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21290/" ]
I'm familiar with [how to set custom messages for post updates](https://wordpress.stackexchange.com/questions/17885/set-custom-messages-for-post-update-save) using the `post_updated_messages` action hook. This question is slightly different. I have a function/action hook on `post_updated`: ``` function my_custom_func...
Do **NOT** use `query_posts()` - it is **bad**, very bad to be exact. For more information read: * [When should you use WP\_Query vs query\_posts() vs get\_posts()?](https://wordpress.stackexchange.com/q/1753/22534) * [When to use WP\_query(), query\_posts() and pre\_get\_posts](https://wordpress.stackexchange.com/q...
189,151
<pre><code>if(strpos($query, '%get_email%') !== false){ $query = str_replace('%get_email%', get_the_author_meta( 'user_email' ), $query); } </code></pre> <p>Okay so am trying to make a MySQL query and in the plugin I am trying to add a shortcode <code>%get_email%</code> but anyway its not returning any ema...
[ { "answer_id": 189170, "author": "Mohammad Mursaleen", "author_id": 35899, "author_profile": "https://wordpress.stackexchange.com/users/35899", "pm_score": 2, "selected": false, "text": "<p>If you just need to \"Get Current user email as a return string value\" then you can simply do thi...
2015/05/22
[ "https://wordpress.stackexchange.com/questions/189151", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73510/" ]
``` if(strpos($query, '%get_email%') !== false){ $query = str_replace('%get_email%', get_the_author_meta( 'user_email' ), $query); } ``` Okay so am trying to make a MySQL query and in the plugin I am trying to add a shortcode `%get_email%` but anyway its not returning any email in the actual query. Like...
I will approach like this: ``` global $current_user; get_currentuserinfo(); $email = (string) $current_user->user_email; var_dump($email); ``` You just called got the email from the current\_user array and cast it into string :) that's it
189,152
<p>I have two Brandoo WordPress sites on Azure. Today I recieved a security alert from Microsoft to update to 4.2.2. However, when I try to update WordPress gets stuck in an infinite loop between two screens. The first screen shows this:</p> <pre><code>Database Update Required WordPress has been updated! Before we se...
[ { "answer_id": 195491, "author": "Chris", "author_id": 76722, "author_profile": "https://wordpress.stackexchange.com/users/76722", "pm_score": 1, "selected": false, "text": "<p>Brandoo isn't (sadly) hosted by Azure at the moment. </p>\n\n<p>This plugin is written to be used by version 3....
2015/05/22
[ "https://wordpress.stackexchange.com/questions/189152", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73511/" ]
I have two Brandoo WordPress sites on Azure. Today I recieved a security alert from Microsoft to update to 4.2.2. However, when I try to update WordPress gets stuck in an infinite loop between two screens. The first screen shows this: ``` Database Update Required WordPress has been updated! Before we send you on your...
Brandoo isn't (sadly) hosted by Azure at the moment. This plugin is written to be used by version 3.6. Newer versions make use of queries which will not work on SQL Server. That's why you get those errors. So, you need to keep your version of wordpress at all costs till a newer version of brandoo is released: <https...
189,168
<p>I have been stuck on this for hours and tried all these different methods but none seem to work. I've seen other threads with a similar problem but the solutions are not working for me. I'm hoping someone can help.</p> <p>I have a page with a custom template using the permalink </p> <pre><code>example.com/central ...
[ { "answer_id": 189242, "author": "David Labbe", "author_id": 38434, "author_profile": "https://wordpress.stackexchange.com/users/38434", "pm_score": 1, "selected": false, "text": "<p>Try this, I did a quick test and it worked for me. I created a page called <code>central</code>.</p>\n<p>...
2015/05/23
[ "https://wordpress.stackexchange.com/questions/189168", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73516/" ]
I have been stuck on this for hours and tried all these different methods but none seem to work. I've seen other threads with a similar problem but the solutions are not working for me. I'm hoping someone can help. I have a page with a custom template using the permalink ``` example.com/central ``` This page accep...
[Add a rewrite endpoint](https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint) instead of a rewrite rule and query var. This API function will do both of these things for you. ``` function wpd_add_my_endpoint(){ add_rewrite_endpoint( 'information', EP_PAGES ); } add_action( 'init', 'wpd_add_my_endpoint' );...
189,199
<p>I have an extremely <strong>weird problem</strong> and I cannot figure out what's going on. I REALLY hope someone here might have a clue or else I don't know what to do anymore.</p> <p>So, there's a weird space gap in my footer like so: <img src="https://i.stack.imgur.com/hmyfB.png" alt="enter image description her...
[ { "answer_id": 189365, "author": "Flamenco", "author_id": 72914, "author_profile": "https://wordpress.stackexchange.com/users/72914", "pm_score": 2, "selected": false, "text": "<p>If you're running the Video Download Helper in your browser, try disabling that, and it will likely disappea...
2015/05/23
[ "https://wordpress.stackexchange.com/questions/189199", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6903/" ]
I have an extremely **weird problem** and I cannot figure out what's going on. I REALLY hope someone here might have a clue or else I don't know what to do anymore. So, there's a weird space gap in my footer like so: ![enter image description here](https://i.stack.imgur.com/hmyfB.png) I've done a lot of testing alrea...
Thanks to what Flamenco mentioned I figured it out. If you have the same issue just put the following into your CSS: ``` .vdh-mask { position: absolute; } ``` The gap is caused by the add-on "**Video Download Helper**". There's nothing we can do about it, but at least it can be hidden via CSS.
189,208
<p>I am creating a plugin for WordPress and this plugin depends on another plugin with a specific version. If I enable my plugin without dependent plugin there are fatal error. Is there a way to check this ?</p> <p>I tried looking at source code but WP do not provide any hook for this.</p> <p>Thanks in advance.</p> ...
[ { "answer_id": 189215, "author": "Aryan", "author_id": 55278, "author_profile": "https://wordpress.stackexchange.com/users/55278", "pm_score": 4, "selected": true, "text": "<p>I was searching for the same answer this morning for my plugin AnsPress. So I sneak into WordPress plugin <code>...
2015/05/23
[ "https://wordpress.stackexchange.com/questions/189208", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26385/" ]
I am creating a plugin for WordPress and this plugin depends on another plugin with a specific version. If I enable my plugin without dependent plugin there are fatal error. Is there a way to check this ? I tried looking at source code but WP do not provide any hook for this. Thanks in advance. **--UPDATE--** I am ...
I was searching for the same answer this morning for my plugin AnsPress. So I sneak into WordPress plugin `wp-admin/includes/plugin.php` and got an idea. WordPress check for fatal error while activating plugin, so simplest solution will be trigger a fatal error and this will prevent WordPress to activate the plugin. ...
189,248
<p>I originally have the website working with: (example) www.domainoriginal.com</p> <p>But I want to have another domain (www.domainsecond.com) also use the same Wordpress installation. </p> <p>I have changed the A record in the DNS configuration so www.domainsecond.com points to the correct IP Address but all the li...
[ { "answer_id": 189215, "author": "Aryan", "author_id": 55278, "author_profile": "https://wordpress.stackexchange.com/users/55278", "pm_score": 4, "selected": true, "text": "<p>I was searching for the same answer this morning for my plugin AnsPress. So I sneak into WordPress plugin <code>...
2015/05/24
[ "https://wordpress.stackexchange.com/questions/189248", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73549/" ]
I originally have the website working with: (example) www.domainoriginal.com But I want to have another domain (www.domainsecond.com) also use the same Wordpress installation. I have changed the A record in the DNS configuration so www.domainsecond.com points to the correct IP Address but all the links are still in ...
I was searching for the same answer this morning for my plugin AnsPress. So I sneak into WordPress plugin `wp-admin/includes/plugin.php` and got an idea. WordPress check for fatal error while activating plugin, so simplest solution will be trigger a fatal error and this will prevent WordPress to activate the plugin. ...
189,285
<p>I'm trying to insert a youtube playlist into a page using the following code</p> <p><code>&lt;iframe width="853" heigh![t="480" src="http://www.youtube.com/embed/videoseries?list=&lt;ID-REMOVED&gt;&amp;amp;hl=en_US" frameborder="0" allowfullscreen&gt;&lt;/iframe][1]&gt;</code></p> <p>for some reason, even when the...
[ { "answer_id": 189215, "author": "Aryan", "author_id": 55278, "author_profile": "https://wordpress.stackexchange.com/users/55278", "pm_score": 4, "selected": true, "text": "<p>I was searching for the same answer this morning for my plugin AnsPress. So I sneak into WordPress plugin <code>...
2015/05/24
[ "https://wordpress.stackexchange.com/questions/189285", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73567/" ]
I'm trying to insert a youtube playlist into a page using the following code `<iframe width="853" heigh![t="480" src="http://www.youtube.com/embed/videoseries?list=<ID-REMOVED>&amp;hl=en_US" frameborder="0" allowfullscreen></iframe][1]>` for some reason, even when the ID is there, it comes out like this Sorry about ...
I was searching for the same answer this morning for my plugin AnsPress. So I sneak into WordPress plugin `wp-admin/includes/plugin.php` and got an idea. WordPress check for fatal error while activating plugin, so simplest solution will be trigger a fatal error and this will prevent WordPress to activate the plugin. ...
189,310
<p>I want to remove default jQuery, because I am adding new or latest jQuery. Also I want include some js in my footer. How can I do that?</p> <p>I want to add another different js like a slider js or css in my footer. </p>
[ { "answer_id": 189311, "author": "Bjarni", "author_id": 68130, "author_profile": "https://wordpress.stackexchange.com/users/68130", "pm_score": 6, "selected": true, "text": "<p>This will do the trick when added to your functions file:</p>\n\n<pre><code>if (!is_admin()) add_action(\"wp_en...
2015/05/25
[ "https://wordpress.stackexchange.com/questions/189310", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51547/" ]
I want to remove default jQuery, because I am adding new or latest jQuery. Also I want include some js in my footer. How can I do that? I want to add another different js like a slider js or css in my footer.
This will do the trick when added to your functions file: ``` if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11); function my_jquery_enqueue() { wp_deregister_script('jquery'); wp_register_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js", false, null); wp_...
189,318
<p>I am using Wordpress with Woocommerce, I am on the detail page of the product content-product-single.php.</p> <p>I created several "sub" and I have to print ONLY subcategories associated with that product.</p> <p>I am using this code:</p> <pre><code>$categories = array ( 'type' =&gt; 'product', 'c...
[ { "answer_id": 189325, "author": "Omar Tariq", "author_id": 36718, "author_profile": "https://wordpress.stackexchange.com/users/36718", "pm_score": 1, "selected": false, "text": "<p>Configure, product_id and parent_category_id according to your requirements.</p>\n\n<pre><code>/* This is ...
2015/05/25
[ "https://wordpress.stackexchange.com/questions/189318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73586/" ]
I am using Wordpress with Woocommerce, I am on the detail page of the product content-product-single.php. I created several "sub" and I have to print ONLY subcategories associated with that product. I am using this code: ``` $categories = array ( 'type' => 'product', 'child_of' => 1, 'parent'...
Configure, product\_id and parent\_category\_id according to your requirements. ``` /* This is product id */ $product_id = 1; /* This is the id of the parent category */ $parent_category_id = 8; $cats = get_categories ( array ( 'type' => 'product', 'parent' => $parent_category_id, 'orderby' => 'term_group...
189,320
<p>I am working on Drupal CMS, and Drupal is really grate and <strong>hard</strong>, and now I am going to learn Wordpress.</p> <p>Drupal let users to create different <a href="https://www.drupal.org/node/21947" rel="nofollow">content-type</a>, and each content-type can be different type of input or textarea and etc.....
[ { "answer_id": 189325, "author": "Omar Tariq", "author_id": 36718, "author_profile": "https://wordpress.stackexchange.com/users/36718", "pm_score": 1, "selected": false, "text": "<p>Configure, product_id and parent_category_id according to your requirements.</p>\n\n<pre><code>/* This is ...
2015/05/25
[ "https://wordpress.stackexchange.com/questions/189320", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73587/" ]
I am working on Drupal CMS, and Drupal is really grate and **hard**, and now I am going to learn Wordpress. Drupal let users to create different [content-type](https://www.drupal.org/node/21947), and each content-type can be different type of input or textarea and etc... for example I have a sport website I can defin...
Configure, product\_id and parent\_category\_id according to your requirements. ``` /* This is product id */ $product_id = 1; /* This is the id of the parent category */ $parent_category_id = 8; $cats = get_categories ( array ( 'type' => 'product', 'parent' => $parent_category_id, 'orderby' => 'term_group...
189,331
<p>I'm trying to do a delete action in custom plugin which uses a custom table and extends wp_list_table for showing the data. The problem is, whenever I try to delete the data I get cannot modify header information and I don't know how to fix it. The code: </p> <pre><code> function process_bulk_action() { //...
[ { "answer_id": 189339, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": -1, "selected": false, "text": "<p>Try following code. </p>\n\n<pre><code>add_action('init', 'start_buffer_output');\nfunction start_buffer_outp...
2015/05/25
[ "https://wordpress.stackexchange.com/questions/189331", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73049/" ]
I'm trying to do a delete action in custom plugin which uses a custom table and extends wp\_list\_table for showing the data. The problem is, whenever I try to delete the data I get cannot modify header information and I don't know how to fix it. The code: ``` function process_bulk_action() { //Detect when ...
You cannot redirect inside process\_bulk\_actions() call, by the time Wordpress is processing that file headers were already sent ( do not know exactly why ). You should simply write a message, and use wp\_die( $message ) instead of die(). When you use bulk actions Wordpress redirects that action to the file showing ...
189,348
<p>We are running a wordpress site with Greek content (political &amp; economical analysis) and we want to set up an English site of our site.</p> <p>The English site will be running on its own wordpress installation in a subdomain of the main site. If the primary site is <a href="http://www.analyst.gr" rel="nofollow"...
[ { "answer_id": 189339, "author": "Domain", "author_id": 26523, "author_profile": "https://wordpress.stackexchange.com/users/26523", "pm_score": -1, "selected": false, "text": "<p>Try following code. </p>\n\n<pre><code>add_action('init', 'start_buffer_output');\nfunction start_buffer_outp...
2015/05/25
[ "https://wordpress.stackexchange.com/questions/189348", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70676/" ]
We are running a wordpress site with Greek content (political & economical analysis) and we want to set up an English site of our site. The English site will be running on its own wordpress installation in a subdomain of the main site. If the primary site is <http://www.analyst.gr> then English site will <http://en.an...
You cannot redirect inside process\_bulk\_actions() call, by the time Wordpress is processing that file headers were already sent ( do not know exactly why ). You should simply write a message, and use wp\_die( $message ) instead of die(). When you use bulk actions Wordpress redirects that action to the file showing ...
189,388
<p>Is there a way to get replies of a comment by its ID? I have searched on google but could not find anything about it.</p> <p>For example, I have a comment with ID 123</p> <p>I want to display all the replies that comment ID 123 has.</p> <p>I have tried something like the following but it did not work:</p> <pre><...
[ { "answer_id": 189394, "author": "Gixty", "author_id": 14128, "author_profile": "https://wordpress.stackexchange.com/users/14128", "pm_score": 0, "selected": false, "text": "<p>I think I just found it, please corrent me if I am wrong:</p>\n\n<pre><code>$args = array(\n 'status' =&gt; ...
2015/05/25
[ "https://wordpress.stackexchange.com/questions/189388", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14128/" ]
Is there a way to get replies of a comment by its ID? I have searched on google but could not find anything about it. For example, I have a comment with ID 123 I want to display all the replies that comment ID 123 has. I have tried something like the following but it did not work: ``` $args = array( 'status' =>...
As `comment_ID` is a unique value, there is no need to include the `post_id` in the arguments. This works fine for me: ``` $args = array( 'status' => 'approve', 'number' => '5', 'parent' => 3194 ); $comments = get_comments($args); ``` This will return 5 approved comments whose parent is the comment wit...