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 |
|---|---|---|---|---|---|---|
142,032 | <p>I'm looking to write an SQL query to do the following:</p>
<p>Select all postmeta rows where the meta_value = a post id that does not exist.</p>
<p>For example, postmeta meta_value may equal 235. Usually this would relate to a post (attachment) with 235 as an ID, however, it has been deleted. I want to find any po... | [
{
"answer_id": 142036,
"author": "James Kemp",
"author_id": 10681,
"author_profile": "https://wordpress.stackexchange.com/users/10681",
"pm_score": 2,
"selected": true,
"text": "<p>Of course, minutes after posting this I work it out. The following worked:</p>\n\n<pre><code>SELECT m.*\nFR... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10681/"
] | I'm looking to write an SQL query to do the following:
Select all postmeta rows where the meta\_value = a post id that does not exist.
For example, postmeta meta\_value may equal 235. Usually this would relate to a post (attachment) with 235 as an ID, however, it has been deleted. I want to find any postmeta rows lik... | Of course, minutes after posting this I work it out. The following worked:
```
SELECT m.*
FROM wp_postmeta m
WHERE m.meta_key = 'image'
AND NOT EXISTS (SELECT *
FROM wp_posts p
WHERE m.meta_value = p.ID)
``` |
142,033 | <p>I would like to change the default class of the widget title. Currently it is h2 and I would like it to be h3. I have seen there is the option of customizing css so that h2 looks like h3.</p>
<pre><code>#sidebar h2 {
font-size: 24px;
}
</code></pre>
<p>But then, this may cause a problem if I modify h3 later, h2 wi... | [
{
"answer_id": 142038,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": false,
"text": "<p><code>h2</code> and <code>h3</code> are not html <em>classes</em>, they are <a href=\"http://www.w3schools.co... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142033",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44481/"
] | I would like to change the default class of the widget title. Currently it is h2 and I would like it to be h3. I have seen there is the option of customizing css so that h2 looks like h3.
```
#sidebar h2 {
font-size: 24px;
}
```
But then, this may cause a problem if I modify h3 later, h2 will not follow the changes.... | `h2` and `h3` are not html *classes*, they are [html *tags*](http://www.w3schools.com/tags/tag_hn.asp).
That said, does not exists a default html tag for the widgets, because the format used to output widgets title is set [when the sidebar is registered](http://codex.wordpress.org/Function_Reference/register_sidebar) ... |
142,049 | <p>I have to confess I'm struggling to see how the Wordpress Twenty Fourteen theme picks up templates put in the theme's <code>page-templates</code> folder. Previously I'd create new templates named <code>page-<slug>.php</code> in the theme's root folder, but not now.</p>
<p>I've searched the code for mentions o... | [
{
"answer_id": 142051,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>The important part in any <code>page-slug.php</code> template or a template used as a page template is ... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142049",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9702/"
] | I have to confess I'm struggling to see how the Wordpress Twenty Fourteen theme picks up templates put in the theme's `page-templates` folder. Previously I'd create new templates named `page-<slug>.php` in the theme's root folder, but not now.
I've searched the code for mentions of `page-templates` and not found any w... | The actual query for a Theme's page templates happens in [`wp_get_theme()->get_page_templates()`](http://codex.wordpress.org/Class_Reference/WP_Theme#Get_Custom_Page_Templates) ([source](https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/class-wp-theme.php#L940)), which in turn calls [`get_files()`](http:... |
142,060 | <p>I would like to avoid the <code>include_once()</code> in order to remove one INFO using Theme Check, and when I try to load my Options page using <code>get_template_part('custom-options');</code> it returns the message:</p>
<blockquote>
<p>«Invalid argument supplied for foreach() in [...]/custom-options.php
on ... | [
{
"answer_id": 142051,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>The important part in any <code>page-slug.php</code> template or a template used as a page template is ... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142060",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37313/"
] | I would like to avoid the `include_once()` in order to remove one INFO using Theme Check, and when I try to load my Options page using `get_template_part('custom-options');` it returns the message:
>
> «Invalid argument supplied for foreach() in [...]/custom-options.php
> on line 83».
>
>
>
Where the code is the... | The actual query for a Theme's page templates happens in [`wp_get_theme()->get_page_templates()`](http://codex.wordpress.org/Class_Reference/WP_Theme#Get_Custom_Page_Templates) ([source](https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/class-wp-theme.php#L940)), which in turn calls [`get_files()`](http:... |
142,061 | <p>I want to wrap each sub-menu ul and the tag just before it with a div.</p>
<p>I can create the opening tag using the 'before' attribute of wP-nav_menu like this:</p>
<pre><code>wp_nav_menu(array(
'before' => '<div class="child-wrap">'
));
</code></pre>
<p>The div then needs to close after the link ... | [
{
"answer_id": 142078,
"author": "Douglas.Sesar",
"author_id": 19945,
"author_profile": "https://wordpress.stackexchange.com/users/19945",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items\" rel=\"nofollow\">http:/... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142061",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15846/"
] | I want to wrap each sub-menu ul and the tag just before it with a div.
I can create the opening tag using the 'before' attribute of wP-nav\_menu like this:
```
wp_nav_menu(array(
'before' => '<div class="child-wrap">'
));
```
The div then needs to close after the link but also after the submenu so the output is... | Ifigured it out myself, thanks to reading this: <http://code.tutsplus.com/tutorials/understanding-the-walker-class--wp-25401>
I created a custom walker:
```
class Child_Wrap extends Walker_Nav_Menu
{
function end_el(&$output, $item, $depth)
{
$indent = str_repeat("\t", $depth);
$output .= "$in... |
142,062 | <p>I use wordpress WP-Mail-SMTP plugin to send mails with proper authentication. I have a Ubuntu 12.04 VPS, Nginx, Wordpress 3.9. When I try to send test mails, I can see following main debug message and it's not sending any mail.</p>
<blockquote>
<p>SMTP -> ERROR: Failed to connect to server: Connection timed out (... | [
{
"answer_id": 142078,
"author": "Douglas.Sesar",
"author_id": 19945,
"author_profile": "https://wordpress.stackexchange.com/users/19945",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items\" rel=\"nofollow\">http:/... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142062",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50674/"
] | I use wordpress WP-Mail-SMTP plugin to send mails with proper authentication. I have a Ubuntu 12.04 VPS, Nginx, Wordpress 3.9. When I try to send test mails, I can see following main debug message and it's not sending any mail.
>
> SMTP -> ERROR: Failed to connect to server: Connection timed out (110)
>
>
>
This ... | Ifigured it out myself, thanks to reading this: <http://code.tutsplus.com/tutorials/understanding-the-walker-class--wp-25401>
I created a custom walker:
```
class Child_Wrap extends Walker_Nav_Menu
{
function end_el(&$output, $item, $depth)
{
$indent = str_repeat("\t", $depth);
$output .= "$in... |
142,065 | <p>I've set up custom flows on my Wordpress blog for login, signup, and commenting. I would like to password protect the standard login flow so only I can use it, and block access entirely to the standard comment flow. </p>
<p>My instinct is to use <code>.htaccess</code> to pw protect access to <code>wp-login.php</cod... | [
{
"answer_id": 142319,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 1,
"selected": false,
"text": "<p>All standard login / registration action are done using <code>'wp-login.php'</code> file.</p>\n\n<p>The stand... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142065",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14366/"
] | I've set up custom flows on my Wordpress blog for login, signup, and commenting. I would like to password protect the standard login flow so only I can use it, and block access entirely to the standard comment flow.
My instinct is to use `.htaccess` to pw protect access to `wp-login.php` and `wp-signup.php`. Is this ... | **This is a pure .htaccess solution.** For a solution using purely WordPress functions, see [G. M.'s answer below](https://wordpress.stackexchange.com/questions/142065/how-to-block-access-to-standard-login-flow-and-comment-flow/142319#142319).
As G. M. pointed out in their answer,
>
> All standard login / registrati... |
142,086 | <p>How would one get posts that are set to 'future' to display in a loop? I am trying to figure out how to get posts that are in the future months. So if we are in April I want to display posts for May. Think of it as a coming up posts.</p>
<p>I have been looking at </p>
<p><a href="http://codex.wordpress.org/Funct... | [
{
"answer_id": 142319,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 1,
"selected": false,
"text": "<p>All standard login / registration action are done using <code>'wp-login.php'</code> file.</p>\n\n<p>The stand... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50055/"
] | How would one get posts that are set to 'future' to display in a loop? I am trying to figure out how to get posts that are in the future months. So if we are in April I want to display posts for May. Think of it as a coming up posts.
I have been looking at
<http://codex.wordpress.org/Function_Reference/WP_Query#Date... | **This is a pure .htaccess solution.** For a solution using purely WordPress functions, see [G. M.'s answer below](https://wordpress.stackexchange.com/questions/142065/how-to-block-access-to-standard-login-flow-and-comment-flow/142319#142319).
As G. M. pointed out in their answer,
>
> All standard login / registrati... |
142,117 | <p>My attachments are currently rewritten from<br>
<code>http://localhost/?attachment_id=3</code> to<br>
<code>http://localhost/images/image-title</code> using @Bainternet's answer <a href="https://wordpress.stackexchange.com/questions/14924/pretty-urls-or-permalinks-for-attachments#answer-14931">here</a>. </p>
<pre>... | [
{
"answer_id": 142600,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>Your rule works with the attachment ID, so I'm not sure how you're using the title, but the answer is almost identi... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2825/"
] | My attachments are currently rewritten from
`http://localhost/?attachment_id=3` to
`http://localhost/images/image-title` using @Bainternet's answer [here](https://wordpress.stackexchange.com/questions/14924/pretty-urls-or-permalinks-for-attachments#answer-14931).
```
$new_rules['images/(\d*)$'] = 'index.php?at... | Your rule works with the attachment ID, so I'm not sure how you're using the title, but the answer is almost identical in either case. The filter you want is `attachment_link`:
```
function wpd_attachment_link( $link, $post_id ){
$post = get_post( $post_id );
return home_url( '/images/' . $post->post_title );
... |
142,123 | <p>I'm working with a plugin that declares a function using this format:</p>
<pre><code>if (!function_exists('ABdevDND_get_current_post_type')){
function ABdevDND_get_current_post_type() {
...
}
}
</code></pre>
<p>I'm trying to declare it in my theme's functions.php file, by just using: </p>
<pre><cod... | [
{
"answer_id": 142124,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>You cannot do that in a theme, because themes are loaded <em>after</em> plugins.</p>\n\n<p>Use a custom plugin, maybe... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142123",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49384/"
] | I'm working with a plugin that declares a function using this format:
```
if (!function_exists('ABdevDND_get_current_post_type')){
function ABdevDND_get_current_post_type() {
...
}
}
```
I'm trying to declare it in my theme's functions.php file, by just using:
```
function ABdevDND_get_current_post_... | You cannot do that in a theme, because themes are loaded *after* plugins.
Use a custom plugin, maybe a mu-plugin to be sure, because they are loaded earlier than normal plugins. |
142,125 | <p>By default running content through <code>the_content</code> filter automatically checks for oEmbed content. However when returning data through <code>heartbeat_received</code> the filter for oEmbed doesn't seem to work.</p>
<p>For example -</p>
<pre><code>function test_heartbeat_received( $response, $data ) {
... | [
{
"answer_id": 142357,
"author": "Ravi Patel",
"author_id": 35477,
"author_profile": "https://wordpress.stackexchange.com/users/35477",
"pm_score": 0,
"selected": false,
"text": "<pre><code>function test_heartbeat_received( $response, $data ) {\n if( $data['test_heartbeat'] == 'test' ... | 2014/04/22 | [
"https://wordpress.stackexchange.com/questions/142125",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6824/"
] | By default running content through `the_content` filter automatically checks for oEmbed content. However when returning data through `heartbeat_received` the filter for oEmbed doesn't seem to work.
For example -
```
function test_heartbeat_received( $response, $data ) {
if( $data['test_heartbeat'] == 'test' ) {
... | The problem:
------------
The reason why this isn't working, is this part of the `WP_Embed::shortcode()` method:
```
if( $post_ID ) {
.... cut ...
// Use oEmbed to get the HTML
$html = wp_oembed_get( $url, $attr );
... cut ...
}
```
When trying to autoembed with the Heartbeat API the `$post_ID` ... |
142,143 | <p>I want to show ads by Google between text content, like show 3 ads one after 1st para second after 3rd para and one at end of last para.</p>
<p>I know i have to modify in <code>single.php</code> but being novice in php I am unable to do this.</p>
<p>Would be real helpful if someone could help me do this. Thanks.</... | [
{
"answer_id": 142152,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 1,
"selected": false,
"text": "<p>Here is the function I use to add a widget after the second paragraph in a post. This is only for the f... | 2014/04/23 | [
"https://wordpress.stackexchange.com/questions/142143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15633/"
] | I want to show ads by Google between text content, like show 3 ads one after 1st para second after 3rd para and one at end of last para.
I know i have to modify in `single.php` but being novice in php I am unable to do this.
Would be real helpful if someone could help me do this. Thanks. | You can use a shortcode or [`the_content` filter](https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content). I think `the_content` filter is better because your don't introduce any string in your post, so the content can be exported and used in another platforms if needed. For emxample, for show a block of a... |
142,191 | <p>Is there a way to create a simple function that redirects every page of a site to another site?</p>
<p>I've Googled around but all the plugins / functions that I've found are only really meant for redirecting individual pages and not entire sites.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 142192,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://wordpress.org/plugins/redirection/\" rel=\"nofollow\">Redirection</a> plugin gives y... | 2014/04/23 | [
"https://wordpress.stackexchange.com/questions/142191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19319/"
] | Is there a way to create a simple function that redirects every page of a site to another site?
I've Googled around but all the plugins / functions that I've found are only really meant for redirecting individual pages and not entire sites.
Any ideas? | While the plugin might solve your problem you could try something direct with WordPress API:
```
add_action( 'template_redirect', 'wpse_142191_all_redirect' );
function wpse_142191_all_redirect() {
if ( !is_user_logged_in() ) {
wp_redirect( 'http://other-site.com', 301);
exit; //always die or... |
142,207 | <p>I have a custom post type 'license' with custom post statuses 'active,inactive,cancel,expire'. However when I run a get_posts query to get only posts with active status it returns all the posts irrespective of the status.</p>
<pre><code>$active_licenses = get_posts( array(
'post_type' => 'license',
... | [
{
"answer_id": 142227,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 1,
"selected": false,
"text": "<p>This error clearly shows that you have a problem with a plugin called 'one-category-only'. You did not ... | 2014/04/23 | [
"https://wordpress.stackexchange.com/questions/142207",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7598/"
] | I have a custom post type 'license' with custom post statuses 'active,inactive,cancel,expire'. However when I run a get\_posts query to get only posts with active status it returns all the posts irrespective of the status.
```
$active_licenses = get_posts( array(
'post_type' => 'license',
'post_status'... | The problem turned out to be a simple overlooked issue: we are using WPEngine's Git, and each time we pushed we were pushing our plugins with it. After adding the plugins directory to the .gitignore (the whole wp-content directory, actually) all was well. |
142,216 | <p>I have tried the following phpMyAdmin query in an effort to delete all posts, from wordpress category 378, that are over 400 days old.</p>
<pre><code>DELETE a,b,c,d
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN wp_term_taxonomy ... | [
{
"answer_id": 254371,
"author": "Tamer Aljabali",
"author_id": 112032,
"author_profile": "https://wordpress.stackexchange.com/users/112032",
"pm_score": -1,
"selected": false,
"text": "<p>you have to add \n\"AND a.post_type='post'\"</p>\n\n<pre><code>delete a,b,c,d\nFROM wp_posts a\nLEF... | 2014/04/23 | [
"https://wordpress.stackexchange.com/questions/142216",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50609/"
] | I have tried the following phpMyAdmin query in an effort to delete all posts, from wordpress category 378, that are over 400 days old.
```
DELETE a,b,c,d
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON ( a.ID = b.object_id )
LEFT JOIN wp_postmeta c ON ( a.ID = c.post_id )
LEFT JOIN wp_term_taxonomy d ON ( d.term_... | Addition note and **warning:** always always always take backups before doing anything in your database. It's very easy to do something you didn't mean to and lose tons of data, especially when dealing with `DELETE` statements. Also, if your database is using InnoDB for the database engine, you can use [transactions](h... |
142,241 | <p>I'm trying to develop a Wordpress theme and figure out how to provide a local fallback for Font Awesome if CDN fails or I develop my theme on a local server without internet connection.</p>
<p>The solution I have in mind is something like this (pseudo code):</p>
<pre><code>if ( $CDN_IS_AVAILABLE ) {
wp_en... | [
{
"answer_id": 142301,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 5,
"selected": true,
"text": "<p>The problem is that I'm pretty sure it's <strong>impossible</strong> to check if CSS is effectively added to a... | 2014/04/24 | [
"https://wordpress.stackexchange.com/questions/142241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33903/"
] | I'm trying to develop a Wordpress theme and figure out how to provide a local fallback for Font Awesome if CDN fails or I develop my theme on a local server without internet connection.
The solution I have in mind is something like this (pseudo code):
```
if ( $CDN_IS_AVAILABLE ) {
wp_enqueue_style( 'font-aw... | The problem is that I'm pretty sure it's **impossible** to check if CSS is effectively added to a page via PHP: CSS is parsed by the browser, so client side, and has completely no effect on server side.
Of course, in PHP it's possible to check if CDN is responsive or not...
### Option 1
Send a request and if it resp... |
142,257 | <p>I need a way to link to the first and the last post (CPT) created.</p>
<p>For example, I'm in the last post and if I click in "next" I should go to the first.</p>
<p>Now i have this</p>
<pre><code><?php
$next_post = get_next_post();
if ( ! empty( $next_post ) ) : ?>
<div id="nextpost"... | [
{
"answer_id": 142267,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": false,
"text": "<p>Firts / last post make sense if we have an order to refer to. <code>get_next_post()</code> function use post ... | 2014/04/24 | [
"https://wordpress.stackexchange.com/questions/142257",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47959/"
] | I need a way to link to the first and the last post (CPT) created.
For example, I'm in the last post and if I click in "next" I should go to the first.
Now i have this
```
<?php
$next_post = get_next_post();
if ( ! empty( $next_post ) ) : ?>
<div id="nextpost" >
<a href="<?php echo get_permalink( $next_post->... | Firts / last post make sense if we have an order to refer to. `get_next_post()` function use post date to *decide* which post is the next. It optionally use also taxonomy, but once you use the function without any argument, only date is relevant, so the *first post* is **the most recent post in same post type**.
To ge... |
142,268 | <p>Is there any way to order posts by category name?</p>
<p>I tried </p>
<pre><code>$args = array(
'post_type' => 'dlm_download',
'posts_per_page' => 10,
'paged' => $paged,
'order_by'=> 'cat',
'order' => 'ASC'
);
</code></pre>
<p>But it does not really work, could please someone g... | [
{
"answer_id": 142296,
"author": "Tyler Carter",
"author_id": 16921,
"author_profile": "https://wordpress.stackexchange.com/users/16921",
"pm_score": 0,
"selected": false,
"text": "<p>The problem here is that you could have multiple categories assigned to a single post. In that case, whi... | 2014/04/24 | [
"https://wordpress.stackexchange.com/questions/142268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50044/"
] | Is there any way to order posts by category name?
I tried
```
$args = array(
'post_type' => 'dlm_download',
'posts_per_page' => 10,
'paged' => $paged,
'order_by'=> 'cat',
'order' => 'ASC'
);
```
But it does not really work, could please someone give me a hint? | I had the same struggle like you, thank i sat down and rethought the whole thing, what you actually need to is select all the categories, and pass the category id to it.
Since you use a dlm\_download you will need to do the following, get the terms from the dlm\_download\_category
```
$cats = get_terms('dlm_download_... |
142,269 | <p>I have a webpage with posts which belong to specific categories (eg <em>projects</em>). I want to show the archive of a specific category like a page.</p>
<h1>Status quo</h1>
<p>The site structure is similar to this:</p>
<blockquote>
<p>/<br>
/our-work/<br>
<strong>/our-work/projects</strong> <- her... | [
{
"answer_id": 142297,
"author": "Tyler Carter",
"author_id": 16921,
"author_profile": "https://wordpress.stackexchange.com/users/16921",
"pm_score": 2,
"selected": true,
"text": "<p>You can register a custom post type with a custom slug permalink structure.</p>\n\n<pre><code>$args = arr... | 2014/04/24 | [
"https://wordpress.stackexchange.com/questions/142269",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32173/"
] | I have a webpage with posts which belong to specific categories (eg *projects*). I want to show the archive of a specific category like a page.
Status quo
==========
The site structure is similar to this:
>
> /
>
> /our-work/
>
> **/our-work/projects** <- here I want to have the archive for *projects*
>
>... | You can register a custom post type with a custom slug permalink structure.
```
$args = array(
'rewrite' => array( 'slug' => 'our-work/book' ),
);
register_post_type( 'projects', $args );
``` |
142,281 | <p>Is it possible to link to the next/prev posts in index.php with <code>query_posts('cat=56');</code> before loop?</p>
<pre><code><?php query_posts('cat=56');
if (have_posts()) : while (have_posts()) : the_post(); ?>
next post title
<?php the_title(); ?>
previous post title
<?php endwhile; ?>
&... | [
{
"answer_id": 142285,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>Naughty boy you, you should never use <a href=\"http://codex.wordpress.org/Function_Reference/query_post... | 2014/04/24 | [
"https://wordpress.stackexchange.com/questions/142281",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38560/"
] | Is it possible to link to the next/prev posts in index.php with `query_posts('cat=56');` before loop?
```
<?php query_posts('cat=56');
if (have_posts()) : while (have_posts()) : the_post(); ?>
next post title
<?php the_title(); ?>
previous post title
<?php endwhile; ?>
<?php endif; ?>
```
next/previous\_post\_l... | Naughty boy you, you should never use [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts). Straight from the codex:
>
> Note: This function isn't meant to be used by plugins or themes. As
> explained later, there are better, more performant options to alter
> the main query. query\_posts() is... |
142,284 | <p>I have 5 different custom post types. I am showing 15 latest post from them on my home page using following query:</p>
<pre><code>$query = new WP_Query( array (
'posts_per_page' => 15,
'post_type' => array ( 'cpt1', 'cpt2', 'cpt3', 'cpt4', 'cpt5' )
)
);
</code></pre>
<... | [
{
"answer_id": 142294,
"author": "Tyler Carter",
"author_id": 16921,
"author_profile": "https://wordpress.stackexchange.com/users/16921",
"pm_score": 0,
"selected": false,
"text": "<p>There is no way to do this in a single query. You must separate it out into multiple queries as SQL comm... | 2014/04/24 | [
"https://wordpress.stackexchange.com/questions/142284",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28744/"
] | I have 5 different custom post types. I am showing 15 latest post from them on my home page using following query:
```
$query = new WP_Query( array (
'posts_per_page' => 15,
'post_type' => array ( 'cpt1', 'cpt2', 'cpt3', 'cpt4', 'cpt5' )
)
);
```
It works fine, shows latest 15... | I am not sure, if this is the most efficient option or not, but I have doen it in following way:
1. I have stored 5 separate query using `get_posts` and stored them in a single array
2. I had to flatten the array, since it was multidimensional. Then used `usort` using `post_date` to get the latest post
3. I have saved... |
142,298 | <p>I want to add one custom meta box to a specific custom meta type "chifres" and two custom meta boxes to a specific custom meta type "presse". This is how far I've gotten:</p>
<p>Here is my code:</p>
<pre><code>//Add custom metadata
function add_custom_metadata_boxes() {
add_meta_box(
'custom_meta_b... | [
{
"answer_id": 142302,
"author": "Joe",
"author_id": 34273,
"author_profile": "https://wordpress.stackexchange.com/users/34273",
"pm_score": -1,
"selected": false,
"text": "<p>This might not be a solution you're looking for, but if you're looking for custom field/box functionality in the... | 2014/04/24 | [
"https://wordpress.stackexchange.com/questions/142298",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50215/"
] | I want to add one custom meta box to a specific custom meta type "chifres" and two custom meta boxes to a specific custom meta type "presse". This is how far I've gotten:
Here is my code:
```
//Add custom metadata
function add_custom_metadata_boxes() {
add_meta_box(
'custom_meta_box', // $id
'... | The [`add_meta_box()`](http://codex.wordpress.org/Function_Reference/add_meta_box) functions 4th parameter is where you add your CPT's for the backend.
```
$post_type
(string) (required) The type of Write screen on which to show the edit screen section ('post', 'page', 'dashboard', 'link', 'attachment' or 'custom_post... |
142,309 | <p>I'm currently developing a website and am exploring all possible options to restrict file viewing. I'm trying to find a way where I can load php files like my theme-options.php and cpt.php without them been displayed in the admin panel even to admin users e.g appearance > editor. </p>
<p>I'm leaning towards the ans... | [
{
"answer_id": 142302,
"author": "Joe",
"author_id": 34273,
"author_profile": "https://wordpress.stackexchange.com/users/34273",
"pm_score": -1,
"selected": false,
"text": "<p>This might not be a solution you're looking for, but if you're looking for custom field/box functionality in the... | 2014/04/24 | [
"https://wordpress.stackexchange.com/questions/142309",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32672/"
] | I'm currently developing a website and am exploring all possible options to restrict file viewing. I'm trying to find a way where I can load php files like my theme-options.php and cpt.php without them been displayed in the admin panel even to admin users e.g appearance > editor.
I'm leaning towards the answer having... | The [`add_meta_box()`](http://codex.wordpress.org/Function_Reference/add_meta_box) functions 4th parameter is where you add your CPT's for the backend.
```
$post_type
(string) (required) The type of Write screen on which to show the edit screen section ('post', 'page', 'dashboard', 'link', 'attachment' or 'custom_post... |
142,311 | <p>I am getting this error after loading my php page: </p>
<blockquote>
<p>Parse error: syntax error, unexpected end of file in
/Applications/XAMPP/xamppfiles/htdocs/wordpress2/wp-content/themes/annonciation/page-42.php
on line 77</p>
</blockquote>
<p>I could understand that it means that I have opened a certai... | [
{
"answer_id": 142325,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<pre><code>if($the_query->have_posts() ) : {\n</code></pre>\n\n<p>Curly braces or colon/end syntax? Pick one... | 2014/04/24 | [
"https://wordpress.stackexchange.com/questions/142311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50800/"
] | I am getting this error after loading my php page:
>
> Parse error: syntax error, unexpected end of file in
> /Applications/XAMPP/xamppfiles/htdocs/wordpress2/wp-content/themes/annonciation/page-42.php
> on line 77
>
>
>
I could understand that it means that I have opened a certain bracket or parenthasis somew... | I just want to add to the two answers given on this matter. It is important to know that if you use
```
if($the_query->have_posts() ) :
```
you will need to close that with
```
endif;
```
otherwise you will also get the same parse error as described. |
142,342 | <p>I have the following secondary navigation menu on my website which has been built using the native <em>WordPress Appearance > Menus</em> feature:</p>
<p><img src="https://i.stack.imgur.com/uVVl4.png" alt="secondary navigation menu"></p>
<hr>
<p>I am also using the following lines of code in my <strong>functions.p... | [
{
"answer_id": 142348,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>You can log someone out without using the standard logout page via the <a href=\"https://codex.wordpress.org/Funct... | 2014/04/25 | [
"https://wordpress.stackexchange.com/questions/142342",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28275/"
] | I have the following secondary navigation menu on my website which has been built using the native *WordPress Appearance > Menus* feature:

---
I am also using the following lines of code in my **functions.php** file to remove and add the '*Login / Reg... | Not tested, but it might work, use `wp_logout_url()` wordpress in built function to get logout url.
```
// Add a Login hyperlink to the secondary navigation menu if the user is logged-out
function wpa_remove_menu_item( $items, $menu, $args ) {
if( is_admin() || ! is_user_logged_in() ) return $items;
foreach (... |
142,383 | <p>I have added a new button that creates a short code but it seems that after the newest WordPress update, the button is not working any more. The button is visible but when someone clicks it, nothing happens.</p>
<p>The code I used is the following- <strong>js part</strong></p>
<pre><code>(function() {
tinymce.crea... | [
{
"answer_id": 142366,
"author": "Keith Groben",
"author_id": 2883,
"author_profile": "https://wordpress.stackexchange.com/users/2883",
"pm_score": 0,
"selected": false,
"text": "<p>The plug in from wordpress.org are community driven. So while there is no guarantee, the larger community ... | 2014/04/25 | [
"https://wordpress.stackexchange.com/questions/142383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26960/"
] | I have added a new button that creates a short code but it seems that after the newest WordPress update, the button is not working any more. The button is visible but when someone clicks it, nothing happens.
The code I used is the following- **js part**
```
(function() {
tinymce.create('tinymce.plugins.affiliate', {
... | Plugins on wordpress.org has always been a debateble question for me. According to my opinion all plugins submitted to wordpress.org should be tested thoroughly and should be bug free.
However, I come across many highly used plugins that are not up to scratch. More that 50 percent of plugins I've tested have some kin... |
142,394 | <p>Hi I'm writing a plugin to include custom search results.
I'm not really allowed to edit any theme pages, but the search results page
in twentyfourteen's search.php seem hardcoded to me:</p>
<pre><code> <header class="page-header">
<h1 class="page-title"><?php printf( __( 'Search R... | [
{
"answer_id": 142366,
"author": "Keith Groben",
"author_id": 2883,
"author_profile": "https://wordpress.stackexchange.com/users/2883",
"pm_score": 0,
"selected": false,
"text": "<p>The plug in from wordpress.org are community driven. So while there is no guarantee, the larger community ... | 2014/04/25 | [
"https://wordpress.stackexchange.com/questions/142394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Hi I'm writing a plugin to include custom search results.
I'm not really allowed to edit any theme pages, but the search results page
in twentyfourteen's search.php seem hardcoded to me:
```
<header class="page-header">
<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentyfourt... | Plugins on wordpress.org has always been a debateble question for me. According to my opinion all plugins submitted to wordpress.org should be tested thoroughly and should be bug free.
However, I come across many highly used plugins that are not up to scratch. More that 50 percent of plugins I've tested have some kin... |
142,404 | <p>I have this slider on my front page. Right now when I click on an image it goes directly to the permalink and the post. How do I make all the slides go to one specific page? </p>
<p>this is the loop for the slider: </p>
<pre><code><ul class="tm_magzslider">
<?php
$recent = new WP_Query( array( "... | [
{
"answer_id": 142366,
"author": "Keith Groben",
"author_id": 2883,
"author_profile": "https://wordpress.stackexchange.com/users/2883",
"pm_score": 0,
"selected": false,
"text": "<p>The plug in from wordpress.org are community driven. So while there is no guarantee, the larger community ... | 2014/04/25 | [
"https://wordpress.stackexchange.com/questions/142404",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50141/"
] | I have this slider on my front page. Right now when I click on an image it goes directly to the permalink and the post. How do I make all the slides go to one specific page?
this is the loop for the slider:
```
<ul class="tm_magzslider">
<?php
$recent = new WP_Query( array( "cat" => $tmcategory,
... | Plugins on wordpress.org has always been a debateble question for me. According to my opinion all plugins submitted to wordpress.org should be tested thoroughly and should be bug free.
However, I come across many highly used plugins that are not up to scratch. More that 50 percent of plugins I've tested have some kin... |
142,425 | <p>How do I simply grab the taxonomy of a post using the post id? I have tried using the_terms and such but everything seems to require you know the taxonomy ahead of time. </p>
| [
{
"answer_id": 142433,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>All I need is to find the taxonomy(ies) of post of a custom post type.\n It can output in an... | 2014/04/25 | [
"https://wordpress.stackexchange.com/questions/142425",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45855/"
] | How do I simply grab the taxonomy of a post using the post id? I have tried using the\_terms and such but everything seems to require you know the taxonomy ahead of time. | >
> All I need is to find the taxonomy(ies) of post of a custom post type.
> It can output in any look or format and I can make it work
>
>
>
That being the case, what you need is [`get_object_taxonomies()`](https://codex.wordpress.org/Function_Reference/get_object_taxonomies)
```
$taxonomies = get_object_taxono... |
142,439 | <p>Im creating a theme based on blankslate/Bootstrap and having an issue with the main nav appearing on category pages (seems to appear everywhere else ok.).</p>
<p>In header.php:</p>
<pre><code><div class="collapse navbar-collapse" id="navbar-collapse-1">
<?php
wp... | [
{
"answer_id": 233628,
"author": "AndyDeGroo",
"author_id": 13045,
"author_profile": "https://wordpress.stackexchange.com/users/13045",
"pm_score": 3,
"selected": false,
"text": "<p>I know this question is quite old but since there is no answer yet an there are many similar questions on ... | 2014/04/25 | [
"https://wordpress.stackexchange.com/questions/142439",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50836/"
] | Im creating a theme based on blankslate/Bootstrap and having an issue with the main nav appearing on category pages (seems to appear everywhere else ok.).
In header.php:
```
<div class="collapse navbar-collapse" id="navbar-collapse-1">
<?php
wp_nav_menu( array(
... | I know this question is quite old but since there is no answer yet an there are many similar questions on the WordPress support forums, I'll better share my findings and maybe help someone.
The issue of disappearing menu may be caused by code in plugin or theme incorrectly modifying global `$wp_query` object using `pr... |
142,451 | <p>Is there any solution to show categories with posts numbers like 'Archives' widget without changing the font size?</p>
<p>UPD0: Sorry if my question is not clear. What I want? We have a pretty nice widget, which generates the following Archives like this:</p>
<p><img src="https://i.stack.imgur.com/i5cy7.png" alt="... | [
{
"answer_id": 173355,
"author": "wp_quick_and_dirty",
"author_id": 65288,
"author_profile": "https://wordpress.stackexchange.com/users/65288",
"pm_score": 3,
"selected": false,
"text": "<p>quick-and-dirty hint to solve this problem:</p>\n\n<ol>\n<li><p>find the function list_translation... | 2014/04/25 | [
"https://wordpress.stackexchange.com/questions/142451",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50842/"
] | Is there any solution to show categories with posts numbers like 'Archives' widget without changing the font size?
UPD0: Sorry if my question is not clear. What I want? We have a pretty nice widget, which generates the following Archives like this:

... | Sooo, apparently the problem was simply that I had forgotten to also upload the new `wp-content/languages` folder that came with the new WP version.
The official doc (at least in French) recommends *not* to upload the `wp-content` folder during the upgrade process (because it contains all the personal files), which is... |
142,476 | <p>I'm stumped. I've been researching this like crazy, but I can't seem to figure out why <code>register_setting()</code> isn't working for me. I'm new to WP plugin development (obviously), so it's probably just something silly that I'm missing. Check it out.</p>
<p>I'm running this in the constructor function:</p>
<... | [
{
"answer_id": 142496,
"author": "Nick Young",
"author_id": 48502,
"author_profile": "https://wordpress.stackexchange.com/users/48502",
"pm_score": 2,
"selected": true,
"text": "<p>I am not exactly sure what you mean by saying that you can see your settings section and fields displayed c... | 2014/04/25 | [
"https://wordpress.stackexchange.com/questions/142476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48162/"
] | I'm stumped. I've been researching this like crazy, but I can't seem to figure out why `register_setting()` isn't working for me. I'm new to WP plugin development (obviously), so it's probably just something silly that I'm missing. Check it out.
I'm running this in the constructor function:
```
add_action( 'admin_ini... | I am not exactly sure what you mean by saying that you can see your settings section and fields displayed correctly, but your my\_plugin\_settings has not been created.
I know sometimes I forget to add the actual admin part in which generally looks something like this:
```
settings_fields( 'my_plugin_settings' );
do... |
142,491 | <p>I have around 2,500+ posts on my site where I've inserted images using the traditional method into the post content itself.</p>
<p>In upgrading to a different theme, the single post page now displays the featured image as well before the title (which I want to keep), but I now would like to remove the first image f... | [
{
"answer_id": 142493,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://wordpress.org/extend/plugins/search-regex/\" rel=\"nofollow\">Search RegEx</a> is a good pl... | 2014/04/26 | [
"https://wordpress.stackexchange.com/questions/142491",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38449/"
] | I have around 2,500+ posts on my site where I've inserted images using the traditional method into the post content itself.
In upgrading to a different theme, the single post page now displays the featured image as well before the title (which I want to keep), but I now would like to remove the first image from the\_c... | Just as @s\_ha\_dum suggests, you can loop through all of your posts and update the content of each one.
The following gives you the idea but is untested:
```
$posts = get_posts( array(
'post_type' => 'post',
'posts_per_page' => 500,
'offset' => 0,
) );
foreach( $posts as $post ):
//... |
142,517 | <p>I am trying to remove some of the admin features for a user with the role of contributor. What i mean by remove some of the admin features is disable them from seeing certain admin menu items, such as comments, tools, media ect. I have managed to remove the items I want from the admin menu, using this code:</p>
<pr... | [
{
"answer_id": 142521,
"author": "Jared Cobb",
"author_id": 6737,
"author_profile": "https://wordpress.stackexchange.com/users/6737",
"pm_score": 1,
"selected": false,
"text": "<p>I typically use (and recommend) the <a href=\"http://wordpress.org/plugins/members/\" rel=\"nofollow\">Membe... | 2014/04/26 | [
"https://wordpress.stackexchange.com/questions/142517",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34375/"
] | I am trying to remove some of the admin features for a user with the role of contributor. What i mean by remove some of the admin features is disable them from seeing certain admin menu items, such as comments, tools, media ect. I have managed to remove the items I want from the admin menu, using this code:
```
functi... | I figured it out in the end and this is the code I used:
```
function restrict_menus() {
$author = wp_get_current_user();
if( isset( $author->roles[0] ) ) {
$current_role = $author->roles[0];
} else {
$current_role = 'no_role';
}
if( 'contributor' == $current_role ) {
$... |
142,530 | <p>I have an front-end ajax login on my site. I want to set the redirect url to <code>'/services/clientarea';</code> for every page that is not part of the blog. For blog pages i want the login redirect to be <code>$_SERVER['REQUEST_URI'];</code></p>
<p>Here is the code that I'm using which isn't working for me:</p>... | [
{
"answer_id": 142533,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 4,
"selected": true,
"text": "<p>OK, let's get some thing staight first.</p>\n\n<p>Here is list of <a href=\"http://codex.wordpress.org... | 2014/04/26 | [
"https://wordpress.stackexchange.com/questions/142530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15846/"
] | I have an front-end ajax login on my site. I want to set the redirect url to `'/services/clientarea';` for every page that is not part of the blog. For blog pages i want the login redirect to be `$_SERVER['REQUEST_URI'];`
Here is the code that I'm using which isn't working for me:
```
function ajax_login_init(){
wp_... | OK, let's get some thing staight first.
Here is list of [actions run during typical request](http://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request). It goes like this:
* ...
* init
* ...
* parse\_request
* ...
* parse\_query
* pre\_get\_posts
* posts\_selection
* ...
* wp
As you... |
142,531 | <p>EDIT: I am still having this issue which is driving me mad - can any help me please?</p>
<p>Thanks!</p>
<p>I have a custom single-blog.php that has a custom yet basic feed.</p>
<p>Here is the code:</p>
<pre><code> <div class="container">
<div class="sixteen columns header">
... | [
{
"answer_id": 142533,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 4,
"selected": true,
"text": "<p>OK, let's get some thing staight first.</p>\n\n<p>Here is list of <a href=\"http://codex.wordpress.org... | 2014/04/26 | [
"https://wordpress.stackexchange.com/questions/142531",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50055/"
] | EDIT: I am still having this issue which is driving me mad - can any help me please?
Thanks!
I have a custom single-blog.php that has a custom yet basic feed.
Here is the code:
```
<div class="container">
<div class="sixteen columns header">
<div class="six columns alpha">
... | OK, let's get some thing staight first.
Here is list of [actions run during typical request](http://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request). It goes like this:
* ...
* init
* ...
* parse\_request
* ...
* parse\_query
* pre\_get\_posts
* posts\_selection
* ...
* wp
As you... |
142,542 | <p>I'm working on a friends site and I am attempting to update the slug <code>example.com/blah</code> but when I update the slug/url to <code>/blah</code> and click ok it updates it to <code>/blah-2</code>. </p>
<p>This means that there is an existing page/post with this setting. I searched the trash/etc in both pages... | [
{
"answer_id": 142544,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Database_Description#Table%3a_wp_posts\" rel=\"nofollow\">The slug is t... | 2014/04/26 | [
"https://wordpress.stackexchange.com/questions/142542",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50888/"
] | I'm working on a friends site and I am attempting to update the slug `example.com/blah` but when I update the slug/url to `/blah` and click ok it updates it to `/blah-2`.
This means that there is an existing page/post with this setting. I searched the trash/etc in both pages and posts and I cannot find one. I hopped ... | [The slug is the poorly named `post_name` column in the `$wpdb->posts` table](http://codex.wordpress.org/Database_Description#Table%3a_wp_posts). Drop this into your theme templates somewhere-- `header.php`, for example-- and you should see any posts with a matching slug:
```
$q = new WP_Query(
array(
'post_type... |
142,546 | <p>I've tried the code below to grab the cat ID for one of my categories (watch-isatv) and exclude all of the posts in that category. However, the posts are not being excluded. What is wrong with the code?</p>
<pre><code>function excludeCat($query) {
if ( $query->is_home ) {
$catid = get_cat_ID('watch-i... | [
{
"answer_id": 142544,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Database_Description#Table%3a_wp_posts\" rel=\"nofollow\">The slug is t... | 2014/04/26 | [
"https://wordpress.stackexchange.com/questions/142546",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18320/"
] | I've tried the code below to grab the cat ID for one of my categories (watch-isatv) and exclude all of the posts in that category. However, the posts are not being excluded. What is wrong with the code?
```
function excludeCat($query) {
if ( $query->is_home ) {
$catid = get_cat_ID('watch-isatv');
$... | [The slug is the poorly named `post_name` column in the `$wpdb->posts` table](http://codex.wordpress.org/Database_Description#Table%3a_wp_posts). Drop this into your theme templates somewhere-- `header.php`, for example-- and you should see any posts with a matching slug:
```
$q = new WP_Query(
array(
'post_type... |
142,569 | <p>Is there a way to automatically run <code>get_header()</code> at the beginning of template and <code>get_footer()</code> at the end of it?</p>
<p>Currently my code is too repetitive with those calls.</p>
<p>I've been looking for a way to do this, but I can't find it in Google.</p>
| [
{
"answer_id": 142570,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>Looking at <code>wp-includes/template-loader.php</code> … there seems to be a way:</p>\n\n<pre><code>if ( $template = ... | 2014/04/27 | [
"https://wordpress.stackexchange.com/questions/142569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33361/"
] | Is there a way to automatically run `get_header()` at the beginning of template and `get_footer()` at the end of it?
Currently my code is too repetitive with those calls.
I've been looking for a way to do this, but I can't find it in Google. | Looking at `wp-includes/template-loader.php` … there seems to be a way:
```
if ( $template = apply_filters( 'template_include', $template ) )
include( $template );
```
You could hook into that filter, handle the including in a callback function and return `FALSE`.
Sample code, not tested:
```
add_filter( 'temp... |
142,605 | <p>Ok, I've a custom post type page to which I have attached the <code>paginate_links</code> function to navigate through the elements.</p>
<p>If I don't do anything and let WP using whatever mechanism is attached to the archive page, then the <code>paginate_links</code> work fine but the previous link never goes back... | [
{
"answer_id": 142611,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/paginate_links\" rel=\"nofollow\"><code>paginate_lin... | 2014/04/27 | [
"https://wordpress.stackexchange.com/questions/142605",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26216/"
] | Ok, I've a custom post type page to which I have attached the `paginate_links` function to navigate through the elements.
If I don't do anything and let WP using whatever mechanism is attached to the archive page, then the `paginate_links` work fine but the previous link never goes back to the page one.
Changing manu... | Ok, the issue seems to be connected with the base and format parameters. I may not able to explain properly technically what has happened.
However, from what I see in my archive page, my page parameter is by default "page" and not "paged" as expected.
That said, when using the base parameter set to '%#%' the hash is ... |
142,732 | <p>Hello there basically I am quite good with WP however it is not easy for me to find a solution to this problem: </p>
<ul>
<li>There is an taxonomy which will consist of hundreds and mayby thousands of items. This taxonomy is called "Stones".</li>
<li>There is a custom post type called "item" (for sale) which consis... | [
{
"answer_id": 142611,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/paginate_links\" rel=\"nofollow\"><code>paginate_lin... | 2014/04/29 | [
"https://wordpress.stackexchange.com/questions/142732",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12035/"
] | Hello there basically I am quite good with WP however it is not easy for me to find a solution to this problem:
* There is an taxonomy which will consist of hundreds and mayby thousands of items. This taxonomy is called "Stones".
* There is a custom post type called "item" (for sale) which consists of 1..n "stones" i... | Ok, the issue seems to be connected with the base and format parameters. I may not able to explain properly technically what has happened.
However, from what I see in my archive page, my page parameter is by default "page" and not "paged" as expected.
That said, when using the base parameter set to '%#%' the hash is ... |
142,811 | <p>How can I exclude pages for logged-in members from WordPress search results?</p>
| [
{
"answer_id": 142812,
"author": "Maidul",
"author_id": 21142,
"author_profile": "https://wordpress.stackexchange.com/users/21142",
"pm_score": -1,
"selected": false,
"text": "<p>You can use this code on your theme <code>functions.php</code>. Note that I have not tested this.</p>\n\n<pre... | 2014/04/29 | [
"https://wordpress.stackexchange.com/questions/142811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40684/"
] | How can I exclude pages for logged-in members from WordPress search results? | Add this to your child themes functions file using a code editor like Notepad++.
You will need to change the page I.D's in the code to your own.
**Exclude Specific Pages From Search Results**
```
add_filter( 'pre_get_posts', 'exclude_pages_search_when_logged_in' );
function exclude_pages_search_when_logged_in($query... |
142,824 | <p>Hello I am trying to send mail with some attachment using with wordpress <code>wp_mail</code> functionality but I am not getting attachment in my mailbox. </p>
<p>Can you please check my bellow code and guide me where I am wrong. You can see I am seeding image in attachment.</p>
<pre><code><?php
$to = 'my@... | [
{
"answer_id": 142825,
"author": "Maidul",
"author_id": 21142,
"author_profile": "https://wordpress.stackexchange.com/users/21142",
"pm_score": 0,
"selected": false,
"text": "<p>You can try this code</p>\n\n<pre><code> $attachments = array( WP_CONTENT_DIR . '/uploads/file_to_attach.zip'... | 2014/04/29 | [
"https://wordpress.stackexchange.com/questions/142824",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26204/"
] | Hello I am trying to send mail with some attachment using with wordpress `wp_mail` functionality but I am not getting attachment in my mailbox.
Can you please check my bellow code and guide me where I am wrong. You can see I am seeding image in attachment.
```
<?php
$to = 'my@email.com';
$subject = 'WordPre... | Attachments should always use the absolute filesystem path.
Also to change the `Content-Type` of the email you should use the `wp_mail_content_type` filter.
```
<?php
function my_custom_email() {
$to = 'my@email.com';
$subject = 'WordPress wp_mail';
$message = '
<html>
<body>
<table rules... |
142,842 | <p>Accordingly to the is_page documentation, supplying the slug as an argument WP can tell me whether the current page is the one represented by the slug. Perhaps I am using the wrong slug?
However I did try both the path used in the rewrite argument as well as the bit I consider to be the "slug" or in other words the... | [
{
"answer_id": 142844,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 3,
"selected": true,
"text": "<p>The creation of a custom post type have it inside the definition, a post type. Also is page only a default post ty... | 2014/04/29 | [
"https://wordpress.stackexchange.com/questions/142842",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26216/"
] | Accordingly to the is\_page documentation, supplying the slug as an argument WP can tell me whether the current page is the one represented by the slug. Perhaps I am using the wrong slug?
However I did try both the path used in the rewrite argument as well as the bit I consider to be the "slug" or in other words the e... | The creation of a custom post type have it inside the definition, a post type. Also is page only a default post type. If you register your custom post type, then check for this post type, not for a page.
### Conditional Tag `is_singular`
The function, conditional tag [`is_singular()`](http://codex.wordpress.org/Funct... |
142,877 | <p>i'm having problem with displaying admin top bar on my site. I googled and got some solution which i tried like<br>
1) Checking wp_footer in footer.php<br>
2) Checkbox ticked in user profile saying show toolbar will viewing site.</p>
<p>All done but no success. please can anyone point me in right direction. I'm usi... | [
{
"answer_id": 142878,
"author": "Stephan Vierkant",
"author_id": 35216,
"author_profile": "https://wordpress.stackexchange.com/users/35216",
"pm_score": 3,
"selected": true,
"text": "<p>It certainly can be a theme related 'problem'. To prevent unexpected problems in a theme, I frequentl... | 2014/04/30 | [
"https://wordpress.stackexchange.com/questions/142877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51039/"
] | i'm having problem with displaying admin top bar on my site. I googled and got some solution which i tried like
1) Checking wp\_footer in footer.php
2) Checkbox ticked in user profile saying show toolbar will viewing site.
All done but no success. please can anyone point me in right direction. I'm using Classicr... | It certainly can be a theme related 'problem'. To prevent unexpected problems in a theme, I frequently disable the admin bar while working on it. Look in functions.php (or similar) for code that looks like this and remove it:
```
function my_function_admin_bar() {
return false;
}
add_filter('show_admin_bar', 'my_... |
142,884 | <p>I'm integrating a separate ecommerce CMS into a wordpress theme, using page templates for some pages such as the basket, search and checkout pages.</p>
<p>This is working out pretty well so far. However, there are a couple of dynamic pages that I'd normally make a single-posttype.php template for, but can't as in t... | [
{
"answer_id": 143106,
"author": "Steven Jones",
"author_id": 24124,
"author_profile": "https://wordpress.stackexchange.com/users/24124",
"pm_score": 4,
"selected": true,
"text": "<p>You can do this by using <strong>pre_get_posts()</strong> which will adjust the query before it's run. Th... | 2014/04/30 | [
"https://wordpress.stackexchange.com/questions/142884",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11332/"
] | I'm integrating a separate ecommerce CMS into a wordpress theme, using page templates for some pages such as the basket, search and checkout pages.
This is working out pretty well so far. However, there are a couple of dynamic pages that I'd normally make a single-posttype.php template for, but can't as in this case I... | You can do this by using **pre\_get\_posts()** which will adjust the query before it's run. Therefore we can exclude pages from the query.
```
function wpse_hide_special_pages($query) {
// Make sure we're in the admin and it's the main query
if ( !is_admin() && !is_main_query() ) {
return;
}
... |
142,888 | <p>I have seen many questions/posts regarding this, but have yet to find a decent solution. Basically I am trying to do what <code>wp_get_archives</code> does, but for a custom post type (personally I am unsure why <code>wp_get_archives</code> doesn't support custom post types!).</p>
<p>The code I am currently using i... | [
{
"answer_id": 142921,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>What you want can be done also filtering <code>'month_link'</code> for monthly archives, <code>'year_link'</co... | 2014/04/30 | [
"https://wordpress.stackexchange.com/questions/142888",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44940/"
] | I have seen many questions/posts regarding this, but have yet to find a decent solution. Basically I am trying to do what `wp_get_archives` does, but for a custom post type (personally I am unsure why `wp_get_archives` doesn't support custom post types!).
The code I am currently using is as follows
**functions.php**... | What you want can be done also filtering `'month_link'` for monthly archives, `'year_link'` for yearly archives and `'day_link'` for daily archives.
You can also write a function that extends `wp_get_archives` to work with CPTs, adding filters to `'getarchives_where'` and to the archive link.
```
function wp_get_cpt_... |
142,896 | <p>I am using the following code in my plugin :</p>
<pre><code><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<?php echo "<script src=".$plugins_url."/mistral/js/jquery.pajinate.js> </script>"; ?>
<script>
$(document).ready(function(){
$(... | [
{
"answer_id": 142901,
"author": "Maidul",
"author_id": 21142,
"author_profile": "https://wordpress.stackexchange.com/users/21142",
"pm_score": 1,
"selected": false,
"text": "<p>To load default wordpess jquery you can use this </p>\n\n<pre><code>add_action( 'wp_enqueue_scripts', 'my_jque... | 2014/04/30 | [
"https://wordpress.stackexchange.com/questions/142896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26393/"
] | I am using the following code in my plugin :
```
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<?php echo "<script src=".$plugins_url."/mistral/js/jquery.pajinate.js> </script>"; ?>
<script>
$(document).ready(function(){
$('#paging_container1').pajinate();
});
</script>
`... | To load default wordpess jquery you can use this
```
add_action( 'wp_enqueue_scripts', 'my_jquery' );
function my_jquery(){
wp_enqueue_script("jquery");
}
```
And use jquery no conflict wrapper to avoid error or on your jquery code
```
(function($) {
// Inside of this function, $() will work as an alias for... |
142,934 | <p>after a few hours serching on the net I decided to ask here my problem.
I'm in a multi site environment and I have this custom post type code:</p>
<pre><code>$products_labels = array(
'name' => _x( 'Prodotti', 'General post type name', 'textdomain' ),
'singular_name' => _x( 'Prodo... | [
{
"answer_id": 143317,
"author": "user2660802",
"author_id": 51063,
"author_profile": "https://wordpress.stackexchange.com/users/51063",
"pm_score": 3,
"selected": true,
"text": "<p>SOLVED. You have to load the load_theme_textdomain not by action but directly written as first line on the... | 2014/04/30 | [
"https://wordpress.stackexchange.com/questions/142934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51063/"
] | after a few hours serching on the net I decided to ask here my problem.
I'm in a multi site environment and I have this custom post type code:
```
$products_labels = array(
'name' => _x( 'Prodotti', 'General post type name', 'textdomain' ),
'singular_name' => _x( 'Prodotto', 'General post ... | SOLVED. You have to load the load\_theme\_textdomain not by action but directly written as first line on the file functions.php Now my custom post type labels are finally translated :) |
142,935 | <p>I have an external script I wrote (for admins only) that loads in the following at the top:</p>
<pre><code>require_once('./../wp-blog-header.php');
</code></pre>
<p>I'm aware that it can be a plugin, but it's just not right now.. it's just a standard php script.</p>
<p>Inside this script I have a form where it al... | [
{
"answer_id": 275855,
"author": "Liz Eipe C",
"author_id": 108014,
"author_profile": "https://wordpress.stackexchange.com/users/108014",
"pm_score": 0,
"selected": false,
"text": "<p>Please use the following code to update the title.As the frist step include the database files.</p>\n\n<... | 2014/04/30 | [
"https://wordpress.stackexchange.com/questions/142935",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11205/"
] | I have an external script I wrote (for admins only) that loads in the following at the top:
```
require_once('./../wp-blog-header.php');
```
I'm aware that it can be a plugin, but it's just not right now.. it's just a standard php script.
Inside this script I have a form where it allows the person viewing to update... | Sometimes I use this code when I want to run WordPress externally.
update.php
```
function find_wordpress_base_path() {
$dir = dirname(__FILE__);
do {
//it is possible to check for other files here
if( file_exists($dir."/wp-config.php") ) {
return $dir;
}
} while( $dir ... |
142,952 | <p>Is there any way of defining a Page Template from some function/filter/hook, without having any .php file containing the comment at the top of the page to declare the Template Name?</p>
<hr />
<p>For example, instead of doing this:</p>
<h3>some-custom-page-template.php</h3>
<pre><code>/**
* Template Name: Some Custo... | [
{
"answer_id": 142956,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>If I understand you, you can do this with the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Referen... | 2014/04/30 | [
"https://wordpress.stackexchange.com/questions/142952",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48313/"
] | Is there any way of defining a Page Template from some function/filter/hook, without having any .php file containing the comment at the top of the page to declare the Template Name?
---
For example, instead of doing this:
### some-custom-page-template.php
```
/**
* Template Name: Some Custom Page Template
*/
```
... | WordPress read the templates from file headers, and then set them in the cache. using [`wp_cache_set()`](http://codex.wordpress.org/Function_Reference/wp_cache_set) nad a key that is derived from the md5 has of stylesheet folder.
So, just overriding that cache we can show the templates we want. To override that cache ... |
142,957 | <p>I was trying to get first 100 words of the content in the header, and I use the following snippet to get the first 100 words in the loop, but is it possible to get the value outside the loop:</p>
<pre><code>$cstring = get_the_content( '' );
$newcString = substr( $cstring, 0, 100 );
echo'<p>' . $newcString . '... | [
{
"answer_id": 142958,
"author": "Maidul",
"author_id": 21142,
"author_profile": "https://wordpress.stackexchange.com/users/21142",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_page\" rel=\"nofollow\">get_page()</a>... | 2014/04/30 | [
"https://wordpress.stackexchange.com/questions/142957",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33233/"
] | I was trying to get first 100 words of the content in the header, and I use the following snippet to get the first 100 words in the loop, but is it possible to get the value outside the loop:
```
$cstring = get_the_content( '' );
$newcString = substr( $cstring, 0, 100 );
echo'<p>' . $newcString . '</p>';
``` | If you are trying to do it for the current page you are on you can just use this:
```
global $post;
$content = $post->post_content;`
```
This will get the content for the current post instead of having to set the ID specifically. |
142,997 | <p>I'm trying to create an option in the WP modal media window to detect duplicate files and delete a newer file if an older duplicate is found. I have the following code working (in conjunction with the 'attachment_fields_to_edit' filter) to deselect a duplicate file and select the original file in the media modal. Wh... | [
{
"answer_id": 142958,
"author": "Maidul",
"author_id": 21142,
"author_profile": "https://wordpress.stackexchange.com/users/21142",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_page\" rel=\"nofollow\">get_page()</a>... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/142997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6678/"
] | I'm trying to create an option in the WP modal media window to detect duplicate files and delete a newer file if an older duplicate is found. I have the following code working (in conjunction with the 'attachment\_fields\_to\_edit' filter) to deselect a duplicate file and select the original file in the media modal. Wh... | If you are trying to do it for the current page you are on you can just use this:
```
global $post;
$content = $post->post_content;`
```
This will get the content for the current post instead of having to set the ID specifically. |
143,005 | <p>When started blogging, I was not aware about the image file's size, and used a lot wider and sharper images without necessity, some of the files are even 5-7mb in size. As there's no such necessity to using such a large file, even the end-user have to wait for a long time loading such images.</p>
<p>I know I can re... | [
{
"answer_id": 142958,
"author": "Maidul",
"author_id": 21142,
"author_profile": "https://wordpress.stackexchange.com/users/21142",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_page\" rel=\"nofollow\">get_page()</a>... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | When started blogging, I was not aware about the image file's size, and used a lot wider and sharper images without necessity, some of the files are even 5-7mb in size. As there's no such necessity to using such a large file, even the end-user have to wait for a long time loading such images.
I know I can replace imag... | If you are trying to do it for the current page you are on you can just use this:
```
global $post;
$content = $post->post_content;`
```
This will get the content for the current post instead of having to set the ID specifically. |
143,018 | <p>I am trying to display post category in a foreach loop. I have all the elements displaying properly except for the category. Here is my function:</p>
<pre><code>function my_get_display_author_posts() {
global $authordata, $post;
$authors_posts = get_posts( array( 'author' => $authordata->ID,'posts_per_page'... | [
{
"answer_id": 143021,
"author": "Maidul",
"author_id": 21142,
"author_profile": "https://wordpress.stackexchange.com/users/21142",
"pm_score": 0,
"selected": false,
"text": "<p><code>the_category()</code> function must be used inside the loop. You can use <a href=\"http://codex.wordpres... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143018",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36035/"
] | I am trying to display post category in a foreach loop. I have all the elements displaying properly except for the category. Here is my function:
```
function my_get_display_author_posts() {
global $authordata, $post;
$authors_posts = get_posts( array( 'author' => $authordata->ID,'posts_per_page' => 6, 'post__not_in'... | When the `foreach` loop is from `get_posts()`, you need to run `setup_postdata()` for each post if you want to use themplate tags inside the loop like `the_category()`, if not you can get unexpected behaviour. Also, you will need to run `wp_reset_postdata()` after the `foreach` loop. Note that `the_category` and simila... |
143,023 | <p>I have managed to integrate a custom taxonomies plugin that:</p>
<p>-Filters down the staff depending on what category is selected.</p>
<p>I want it to show <strong>that department first</strong>, and then the other departments beneath rather than that department all on its own (how it is now).</p>
<p>Here is the... | [
{
"answer_id": 143021,
"author": "Maidul",
"author_id": 21142,
"author_profile": "https://wordpress.stackexchange.com/users/21142",
"pm_score": 0,
"selected": false,
"text": "<p><code>the_category()</code> function must be used inside the loop. You can use <a href=\"http://codex.wordpres... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51100/"
] | I have managed to integrate a custom taxonomies plugin that:
-Filters down the staff depending on what category is selected.
I want it to show **that department first**, and then the other departments beneath rather than that department all on its own (how it is now).
Here is the link:
<http://crippslawtest.co.uk/pe... | When the `foreach` loop is from `get_posts()`, you need to run `setup_postdata()` for each post if you want to use themplate tags inside the loop like `the_category()`, if not you can get unexpected behaviour. Also, you will need to run `wp_reset_postdata()` after the `foreach` loop. Note that `the_category` and simila... |
143,042 | <p>Google seems all purple on this subject, if you know what I mean. I've searched for this topic forever to find a solution.</p>
<p>I want to build a finder/explorer feel to my categories, so when browsing to a category, I only want to display the direct children of the category - not posts in sub categories of this ... | [
{
"answer_id": 143048,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>I assume that by \"direct children of category\" you mean \"posts directly assigned to the category\" and not... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143042",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49175/"
] | Google seems all purple on this subject, if you know what I mean. I've searched for this topic forever to find a solution.
I want to build a finder/explorer feel to my categories, so when browsing to a category, I only want to display the direct children of the category - not posts in sub categories of this category.
... | I assume that by "direct children of category" you mean "posts directly assigned to the category" and not "posts assigned to child categories of the category specified".
The answer is in the Codex:
>
> Display posts that have this category (not children of that category),
> using category id:
>
>
>
> ```
> $quer... |
143,051 | <p>I want editors to be able to list, add and edit users. I thought the following code would do it, but it doesn't work - no new User menu appears for any editors. Have I missed something?</p>
<pre><code>function increase_editor_role(){
$role = get_role('editor');
$role->add_cap('list_users');
$role-... | [
{
"answer_id": 143048,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>I assume that by \"direct children of category\" you mean \"posts directly assigned to the category\" and not... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143051",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7640/"
] | I want editors to be able to list, add and edit users. I thought the following code would do it, but it doesn't work - no new User menu appears for any editors. Have I missed something?
```
function increase_editor_role(){
$role = get_role('editor');
$role->add_cap('list_users');
$role->add_cap('edit_user... | I assume that by "direct children of category" you mean "posts directly assigned to the category" and not "posts assigned to child categories of the category specified".
The answer is in the Codex:
>
> Display posts that have this category (not children of that category),
> using category id:
>
>
>
> ```
> $quer... |
143,056 | <p>Is there a way to get all tags whose slug starts with a specific word? I tried to use the below code but doesn't output anything. What am i missing here? I am new to php so excuse if i am doing something totally wrong.</p>
<pre><code> $auth = get_term_by('slug', 'author-', 'tag');
print "values".$auth;
</code></... | [
{
"answer_id": 143063,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 1,
"selected": true,
"text": "<p>I think its easier to get them all and filter the ones starting with author:</p>\n\n<pre><code><?php\n$tags ... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50903/"
] | Is there a way to get all tags whose slug starts with a specific word? I tried to use the below code but doesn't output anything. What am i missing here? I am new to php so excuse if i am doing something totally wrong.
```
$auth = get_term_by('slug', 'author-', 'tag');
print "values".$auth;
``` | I think its easier to get them all and filter the ones starting with author:
```
<?php
$tags = get_terms( 'tags', array(
'hide_empty' => 0
));
if ( !empty( $tags ) && !is_wp_error( $tags ) ): ?>
<ul>
<?php foreach ( $tags as $tag ): ?>
<?php if(strpos($tag->slug,'author-') !== false): ?>
<l... |
143,068 | <p>I lost my database and when they restored the files, I had two files in a database directory that I assume are the data for my database. How do I recover my database using these two files. wp_options.MYI and wp_options.MYD</p>
<p>Thanks</p>
| [
{
"answer_id": 143063,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 1,
"selected": true,
"text": "<p>I think its easier to get them all and filter the ones starting with author:</p>\n\n<pre><code><?php\n$tags ... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143068",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51114/"
] | I lost my database and when they restored the files, I had two files in a database directory that I assume are the data for my database. How do I recover my database using these two files. wp\_options.MYI and wp\_options.MYD
Thanks | I think its easier to get them all and filter the ones starting with author:
```
<?php
$tags = get_terms( 'tags', array(
'hide_empty' => 0
));
if ( !empty( $tags ) && !is_wp_error( $tags ) ): ?>
<ul>
<?php foreach ( $tags as $tag ): ?>
<?php if(strpos($tag->slug,'author-') !== false): ?>
<l... |
143,070 | <p>I've inserted a <code>WP_Query</code> in my single.php template to show the last 12 posts of an author. Everything works ok, the 12 posts are being shown. </p>
<p>Now, I want to have it paginated. So the user can see more than 12 posts.</p>
<p>Here is my <code>WP_Query</code> and pagination code:</p>
<pre><code>&... | [
{
"answer_id": 143063,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 1,
"selected": true,
"text": "<p>I think its easier to get them all and filter the ones starting with author:</p>\n\n<pre><code><?php\n$tags ... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14128/"
] | I've inserted a `WP_Query` in my single.php template to show the last 12 posts of an author. Everything works ok, the 12 posts are being shown.
Now, I want to have it paginated. So the user can see more than 12 posts.
Here is my `WP_Query` and pagination code:
```
<?php
$paged = get_query_var( 'pag... | I think its easier to get them all and filter the ones starting with author:
```
<?php
$tags = get_terms( 'tags', array(
'hide_empty' => 0
));
if ( !empty( $tags ) && !is_wp_error( $tags ) ): ?>
<ul>
<?php foreach ( $tags as $tag ): ?>
<?php if(strpos($tag->slug,'author-') !== false): ?>
<l... |
143,075 | <p>I've written a small plugin that spits out html for a button. It works great, except for one thing: If the user doesn't specify an image, the image appears broken. Is there a way for me to check and see if the user has specified an image, and only print the image code if that's the case?</p>
<p>Here's my plugin cod... | [
{
"answer_id": 143077,
"author": "Borek",
"author_id": 45286,
"author_profile": "https://wordpress.stackexchange.com/users/45286",
"pm_score": 2,
"selected": false,
"text": "<p>How about just assign a default image to this variable? So if no image is specified a default (instead of empty... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143075",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24566/"
] | I've written a small plugin that spits out html for a button. It works great, except for one thing: If the user doesn't specify an image, the image appears broken. Is there a way for me to check and see if the user has specified an image, and only print the image code if that's the case?
Here's my plugin code:
```
fu... | Borek pointed in the right direction, here's my fine code\*:
```
function button_shortcode($attributes, $content) {
if ($attributes["image"] != "") {
$img = "<img alt=\"" . $content . "\" class=\"alignleft\" src=\"" . $attributes["image"] . "\" />";
} else {
$img = "";
}
if ($attributes... |
143,088 | <p>I am a big fan of Advanced Custom Fields plugin<br>
<a href="http://www.advancedcustomfields.com/" rel="nofollow">http://www.advancedcustomfields.com/</a></p>
<p>I developed a site where there are 2 types of categories:
normal and “custom”
most of the categories display normally like any other site showing
the post... | [
{
"answer_id": 143094,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>The ACF API functions normally work with the current post's ID. Taxonomies and Users work a bit differently, you ha... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7730/"
] | I am a big fan of Advanced Custom Fields plugin
<http://www.advancedcustomfields.com/>
I developed a site where there are 2 types of categories:
normal and “custom”
most of the categories display normally like any other site showing
the posts in the archive.php page
and some posts archive are displaying in a specia... | The ACF API functions normally work with the current post's ID. Taxonomies and Users work a bit differently, you have to supply the ID of the object you want to fetch fields from.
```
$category_id = 'category_' . get_queried_object_id();
$field = get_field( 'post_slider_projects', $category_id );
```
See [`get_field... |
143,091 | <p>I am using custom post types, and I have a problem getting the author URL to his profile.</p>
<p>I can get the author ID using:</p>
<pre><code>$authers_interviewdoctor = get_post_meta( $post->ID , 'authers_interviewdoctor' , true );
</code></pre>
<p>However, I need to get the link to his profile, such as: </p... | [
{
"answer_id": 143094,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>The ACF API functions normally work with the current post's ID. Taxonomies and Users work a bit differently, you ha... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51121/"
] | I am using custom post types, and I have a problem getting the author URL to his profile.
I can get the author ID using:
```
$authers_interviewdoctor = get_post_meta( $post->ID , 'authers_interviewdoctor' , true );
```
However, I need to get the link to his profile, such as:
```
www.example.com/author/admin
``` | The ACF API functions normally work with the current post's ID. Taxonomies and Users work a bit differently, you have to supply the ID of the object you want to fetch fields from.
```
$category_id = 'category_' . get_queried_object_id();
$field = get_field( 'post_slider_projects', $category_id );
```
See [`get_field... |
143,095 | <p>I created new post type and support tags like this:</p>
<pre><code>'supports' => array(
'title',
'thumbnail',
'editor',
'date',
'excerpt',
... | [
{
"answer_id": 143103,
"author": "Steven Jones",
"author_id": 24124,
"author_profile": "https://wordpress.stackexchange.com/users/24124",
"pm_score": 0,
"selected": false,
"text": "<p>You need to specify it as a taxonomy. So in addition to your supports argument you can pass through taxo... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143095",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51121/"
] | I created new post type and support tags like this:
```
'supports' => array(
'title',
'thumbnail',
'editor',
'date',
'excerpt',
'comments',
... | "Tags" are a taxonomy and should be registered using the `taxonomy` argument, not the `supports` argument.
>
>
> >
> > **taxonomies** (array) (optional) An array of registered taxonomies like `category` or `post_tag` that will be used with this post
> > type. This
> > can be used in lieu of calling `register_taxo... |
143,100 | <p>I have created a number of custom post statuses using the EdiFlow plugin. Now, what I am trying to do is, if the contribter visits the post edit page and the post status is "assigned" to automatically change into "work in progress". This would allow me to know and send them an e-mail when they start working on it (o... | [
{
"answer_id": 143128,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>If you want the default post status to be <code>in-progress</code> when <em>contributors</em> click on \"New ... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43332/"
] | I have created a number of custom post statuses using the EdiFlow plugin. Now, what I am trying to do is, if the contribter visits the post edit page and the post status is "assigned" to automatically change into "work in progress". This would allow me to know and send them an e-mail when they start working on it (on p... | After many tests, it seems that this code is working. Please suggest improvements if you have any! I have tested this but I need to test it more thoroughly:
```
function educadme_assigned_to_inprogress() {
global $post;
$id = get_the_ID();
if ( current_user_can('edit_post', $id) && !current_user_can( 'manage_options' ... |
143,102 | <p>I've been trying to figure this out for days, to no avail. </p>
<p>A template I'm building requires a mega menu. The markup for the menu looks like this:</p>
<pre><code><nav>
<ul>
<li><a href="#">General Information</a></li>
<li>
<a href=... | [
{
"answer_id": 143128,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>If you want the default post status to be <code>in-progress</code> when <em>contributors</em> click on \"New ... | 2014/05/01 | [
"https://wordpress.stackexchange.com/questions/143102",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24566/"
] | I've been trying to figure this out for days, to no avail.
A template I'm building requires a mega menu. The markup for the menu looks like this:
```
<nav>
<ul>
<li><a href="#">General Information</a></li>
<li>
<a href="#">Programs</a>
<section>
<ul>
... | After many tests, it seems that this code is working. Please suggest improvements if you have any! I have tested this but I need to test it more thoroughly:
```
function educadme_assigned_to_inprogress() {
global $post;
$id = get_the_ID();
if ( current_user_can('edit_post', $id) && !current_user_can( 'manage_options' ... |
143,122 | <p>I'm successfully using helgatheviking's answer from this post: <a href="https://wordpress.stackexchange.com/questions/65095/show-children-of-top-level-category-only">Show children of top level category only</a> See code below:</p>
<pre><code>// get the category object for the current category
$thisCat = get_categor... | [
{
"answer_id": 143607,
"author": "Arvid Eriksson",
"author_id": 51034,
"author_profile": "https://wordpress.stackexchange.com/users/51034",
"pm_score": 2,
"selected": false,
"text": "<p>I have solved my problem. I added this definition before my old code:</p>\n\n<pre><code><?php\n// g... | 2014/05/02 | [
"https://wordpress.stackexchange.com/questions/143122",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51034/"
] | I'm successfully using helgatheviking's answer from this post: [Show children of top level category only](https://wordpress.stackexchange.com/questions/65095/show-children-of-top-level-category-only) See code below:
```
// get the category object for the current category
$thisCat = get_category( get_query_var( 'cat' )... | I have solved my problem. I added this definition before my old code:
```
<?php
// get the category object for the current category
$thisTrueCat = get_category( get_query_var( 'cat' ) );
print $thisTrueCat->term_id;
?>
```
The above `$thisTrueCat`, different from `$thisCat` in the already existing code, retrieves t... |
143,133 | <p>What's the best way to show a time stamp based on different times? For example: if a post is under 24 hours, show <em>%% mins/hours ago</em>. If a post is over 24 hours, show <em>month/day/time</em>. If a post if over a year ago, show <em>month/day/year/time</em>.</p>
<p>I've done this so far:</p>
<pre><code><?... | [
{
"answer_id": 143138,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>Check out <a href=\"https://codex.wordpress.org/Function_Reference/human_time_diff\" rel=\"nofollow\"><cod... | 2014/05/02 | [
"https://wordpress.stackexchange.com/questions/143133",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8049/"
] | What's the best way to show a time stamp based on different times? For example: if a post is under 24 hours, show *%% mins/hours ago*. If a post is over 24 hours, show *month/day/time*. If a post if over a year ago, show *month/day/year/time*.
I've done this so far:
```
<?php if(get_the_time('G') < 23) {
the_time('Y'... | Thanks for the responses! This is the solution:
```
<?php
if ( DAY_IN_SECONDS < ( $time = current_time( 'timestamp' ) ) - ( $time_post = get_the_time( 'U' ) ) )
echo human_time_diff( $time_post, $time ) . ' ago';
elseif ( WEEK_IN_SECONDS < ( $time - $time_post ) )
the_time( 'D / g:i a' );
elseif ( YEAR_IN_SECO... |
143,152 | <p>I need a little bit of insight here with the following problem? I've created a child theme called 'test_child' which I am trying to extend in the following way:</p>
<p>This is the test_child/functions.php file:</p>
<pre><code><?php
function load_flaticon() {
wp_enqueue_script(
'flaticon', get_s... | [
{
"answer_id": 143164,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>There are two parts in the question I want to address:</p>\n\n<ol>\n<li><p>It didn’t work because the action uses a pl... | 2014/05/02 | [
"https://wordpress.stackexchange.com/questions/143152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51139/"
] | I need a little bit of insight here with the following problem? I've created a child theme called 'test\_child' which I am trying to extend in the following way:
This is the test\_child/functions.php file:
```
<?php
function load_flaticon() {
wp_enqueue_script(
'flaticon', get_stylesheet_directory_ur... | There are two parts in the question I want to address:
1. It didn’t work because the action uses a plural form: `wp_enqueue_scripts`, not `wp_enqueue_script`. I guess this happened, because the function you have to use here – `wp_enqueue_script()` – *does* use a singular.
2. You should not use the function `wp_enqueue... |
143,155 | <p>I have the following code to show current author post lists with post thumbnail, post title, post date and post category. </p>
<pre><code>function my_get_display_author_posts() {
global $authordata, $post;
$authors_posts = get_posts( array( 'author' => $authordata->ID,'posts_per_page' => 6, 'post__not_in'... | [
{
"answer_id": 143158,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": true,
"text": "<p>You are fighting with the post <code>global</code>s, like <code>$post</code>, and are not getting them set co... | 2014/05/02 | [
"https://wordpress.stackexchange.com/questions/143155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36035/"
] | I have the following code to show current author post lists with post thumbnail, post title, post date and post category.
```
function my_get_display_author_posts() {
global $authordata, $post;
$authors_posts = get_posts( array( 'author' => $authordata->ID,'posts_per_page' => 6, 'post__not_in' => array( $post->ID ) ... | You are fighting with the post `global`s, like `$post`, and are not getting them set correctly. Create a proper [Loop](https://codex.wordpress.org/The_Loop) using [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) and use [Core template tags](https://codex.wordpress.org/Template_Tags) where possible and ... |
143,176 | <p>I've recently switched over from using a custom class to enable a theme options panel to the built in Theme Customizer in Wordpress.</p>
<p>All is going fairly well - I've got live preview working but I'm a little bit stuck on using 'get_theme_mod()' to retrieve the values in a dedicated PHP file.</p>
<p>Using my ... | [
{
"answer_id": 158160,
"author": "orionrush",
"author_id": 13551,
"author_profile": "https://wordpress.stackexchange.com/users/13551",
"pm_score": 3,
"selected": false,
"text": "<p>@s_ha_dum is right, the <a href=\"http://codex.wordpress.org/AJAX_in_Plugins\" rel=\"nofollow noreferrer\">... | 2014/05/02 | [
"https://wordpress.stackexchange.com/questions/143176",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37430/"
] | I've recently switched over from using a custom class to enable a theme options panel to the built in Theme Customizer in Wordpress.
All is going fairly well - I've got live preview working but I'm a little bit stuck on using 'get\_theme\_mod()' to retrieve the values in a dedicated PHP file.
Using my old class, I co... | @s\_ha\_dum is right, the [ajax plugin api](http://codex.wordpress.org/AJAX_in_Plugins) is the way to go.
I ran into this issue myself with a dynamic js file I was generating a little while ago.
Basically you would enqueue your style as follows:
```
wp_enqueue_style(
'dynamic-css',
admin_url('admin-ajax.php')... |
143,179 | <p>I have following query to store data for last week entries in database:</p>
<pre><code>for ( $i; $i <= 7; $i++ ) {
$val[$i]= $wpdb->get_results( "SELECT COUNT(`order_total`) AS 'Total' FROM vm_orders WHERE DATE = CURDATE()-$i" );
}
</code></pre>
<p>When I <code>print_r( $var )</code> I get:</p>
<pre... | [
{
"answer_id": 143181,
"author": "Chittaranjan",
"author_id": 43031,
"author_profile": "https://wordpress.stackexchange.com/users/43031",
"pm_score": 2,
"selected": true,
"text": "<p>If you just need to have the <code>print_array($var)</code> provide an array of values, then you need to ... | 2014/05/02 | [
"https://wordpress.stackexchange.com/questions/143179",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49232/"
] | I have following query to store data for last week entries in database:
```
for ( $i; $i <= 7; $i++ ) {
$val[$i]= $wpdb->get_results( "SELECT COUNT(`order_total`) AS 'Total' FROM vm_orders WHERE DATE = CURDATE()-$i" );
}
```
When I `print_r( $var )` I get:
```
Array (
[1] => Array (
[0] => stdCl... | If you just need to have the `print_array($var)` provide an array of values, then you need to change the database function from `$wpdb->get_results` to `$wpdb->get_var`.
You are retrieving just one value from the database, so `get_var` is the function which will return that specific value directly.
Edit:
You can cre... |
143,186 | <p>I know this is a convoluted loop (inherited from someone else), and this must be pretty simple: <code>the_permalink</code> and <code>the_title</code> display OK, but why doesn't my post meta <code>eventdatestart</code> echo?.</p>
<pre><code><?php
$queryObject = new WP_Query( 'post_type=events&posts_per_page=... | [
{
"answer_id": 143190,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 0,
"selected": false,
"text": "<p>Can you confirm the ID is correct? try echoing <code>get_the_ID()</code>. </p>\n\n<p>If that is the issue, maybe t... | 2014/05/02 | [
"https://wordpress.stackexchange.com/questions/143186",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/268/"
] | I know this is a convoluted loop (inherited from someone else), and this must be pretty simple: `the_permalink` and `the_title` display OK, but why doesn't my post meta `eventdatestart` echo?.
```
<?php
$queryObject = new WP_Query( 'post_type=events&posts_per_page=5' );
if ($queryObject->have_posts()) {
?>
<div id="wr... | I think you may need to add `global $post` after the loop starts based on a similar [question found here](http://wordpress.org/support/topic/can-wordpress-wp_query-return-custom-field-post-meta).
```
<?php
while ($queryObject->have_posts()) {
$queryObject->the_post();
global $post;
?>
```
I wish I could explai... |
143,217 | <p>I'd like to inject the name of the author of a post into the header of the page via the author tag.</p>
<p>something like </p>
<pre><code><head>
<title>FAQs</title>
<meta name="author" content="My name">
</head>
</code></pre>
<p>However, I won't be able to find the author nam... | [
{
"answer_id": 143190,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 0,
"selected": false,
"text": "<p>Can you confirm the ID is correct? try echoing <code>get_the_ID()</code>. </p>\n\n<p>If that is the issue, maybe t... | 2014/05/02 | [
"https://wordpress.stackexchange.com/questions/143217",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26216/"
] | I'd like to inject the name of the author of a post into the header of the page via the author tag.
something like
```
<head>
<title>FAQs</title>
<meta name="author" content="My name">
</head>
```
However, I won't be able to find the author name before entering in the loop? So can I still make this change ... | I think you may need to add `global $post` after the loop starts based on a similar [question found here](http://wordpress.org/support/topic/can-wordpress-wp_query-return-custom-field-post-meta).
```
<?php
while ($queryObject->have_posts()) {
$queryObject->the_post();
global $post;
?>
```
I wish I could explai... |
143,224 | <p>I need to dequeue or remove style and script related to "pretty_photo" from my theme but load it again only when it <strong>called or needed</strong> </p>
<p>i have this code in my <code>functions.php</code></p>
<pre><code>wp_enqueue_style('pretty_photo', MASTER_THEME_DIR . '/addons/prettyphoto/prettyPhoto.css',ar... | [
{
"answer_id": 143226,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>First, hacking a theme is generally a bad idea unless it is a theme you've built and maintain. I don't know ... | 2014/05/02 | [
"https://wordpress.stackexchange.com/questions/143224",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50780/"
] | I need to dequeue or remove style and script related to "pretty\_photo" from my theme but load it again only when it **called or needed**
i have this code in my `functions.php`
```
wp_enqueue_style('pretty_photo', MASTER_THEME_DIR . '/addons/prettyphoto/prettyPhoto.css',array() ,false,'all')
``` | I got it to working finally .. The code is:
```
add_action( 'wp_enqueue_scripts', 'pretty_photo_styles', 100 );
function pretty_photo_styles() {
if ( ! is_single() ) {
wp_dequeue_script( 'pretty_photo' );
wp_dequeue_style( 'pretty_photo' );
}
}
```
Please someone correct it if I missed anything!
I tr... |
143,227 | <p>Does wordpress allow me to add a php file to the root directory to execute custom scripts?</p>
<p>I need functionality similar to functions.php that you put into themes.</p>
<p>Are there any work arounds that don't involve modifying the config.php file?</p>
| [
{
"answer_id": 143226,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>First, hacking a theme is generally a bad idea unless it is a theme you've built and maintain. I don't know ... | 2014/05/03 | [
"https://wordpress.stackexchange.com/questions/143227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51167/"
] | Does wordpress allow me to add a php file to the root directory to execute custom scripts?
I need functionality similar to functions.php that you put into themes.
Are there any work arounds that don't involve modifying the config.php file? | I got it to working finally .. The code is:
```
add_action( 'wp_enqueue_scripts', 'pretty_photo_styles', 100 );
function pretty_photo_styles() {
if ( ! is_single() ) {
wp_dequeue_script( 'pretty_photo' );
wp_dequeue_style( 'pretty_photo' );
}
}
```
Please someone correct it if I missed anything!
I tr... |
143,239 | <p>I am trying to build a classic archive page with 10 posts per page.
But with a list of all the posts of this archive to be displayed on top of the classic loop.</p>
<p>(The paginated posts would display feature image, excerpt...
while the list of all post would retain only the permalink)</p>
<p>I keep on thinking... | [
{
"answer_id": 143285,
"author": "Hybrid Web Dev",
"author_id": 36506,
"author_profile": "https://wordpress.stackexchange.com/users/36506",
"pm_score": 0,
"selected": false,
"text": "<p>Pulled directly from wordpresses codex:</p>\n\n<pre><code>// main loop\n<?php if (have_posts()) : w... | 2014/05/03 | [
"https://wordpress.stackexchange.com/questions/143239",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51173/"
] | I am trying to build a classic archive page with 10 posts per page.
But with a list of all the posts of this archive to be displayed on top of the classic loop.
(The paginated posts would display feature image, excerpt...
while the list of all post would retain only the permalink)
I keep on thinking I could use the ... | If you want to accomplish it in a single query, hook `pre_get_posts` to query for all posts:
```
function wpd_archive_all_posts( $query ){
if( $query->is_post_type_archive( 'attractions' ) && $query->is_main_query() )
$query->set( 'posts_per_page', -1 );
}
add_action( 'pre_get_posts', 'wpd_archive_all_post... |
143,240 | <p>I found that my PHP script throws an 500 (Internal Server Error) at the line which <code>wp_generate_attachment_metadata</code> function is used:</p>
<pre><code>$attach_data = wp_generate_attachment_metadata( $attach_id, $fullpathfilename );
</code></pre>
<p>I can exit and take an output before this line but not a... | [
{
"answer_id": 143242,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_generate_attachment_metadata\" rel=\"nofollo... | 2014/05/03 | [
"https://wordpress.stackexchange.com/questions/143240",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26909/"
] | I found that my PHP script throws an 500 (Internal Server Error) at the line which `wp_generate_attachment_metadata` function is used:
```
$attach_data = wp_generate_attachment_metadata( $attach_id, $fullpathfilename );
```
I can exit and take an output before this line but not after that.
I checked the inputs too:... | You might need to require once this file:
```
wp-admin/includes/image.php
``` |
143,241 | <p>I want to get category id from post id of a custom type.
I have the post id, but I can't get it's category id.</p>
<p>I have used so many codes but it doesn't work, may be due to custom post type.</p>
<pre><code>$category = get_the_category( $post->ID );
</code></pre>
<p>Any suggestions?</p>
| [
{
"answer_id": 143246,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>Are your custom post type supporting the standard category taxonomy? If the category used in your custom post... | 2014/05/03 | [
"https://wordpress.stackexchange.com/questions/143241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51177/"
] | I want to get category id from post id of a custom type.
I have the post id, but I can't get it's category id.
I have used so many codes but it doesn't work, may be due to custom post type.
```
$category = get_the_category( $post->ID );
```
Any suggestions? | `wp_get_post_categories` can only get POST categories not a custom post's categories, try this instead:
```
$category = get_the_terms( $post->ID, 'custom-taxonomy-here' );
foreach ( $category as $cat){
echo $cat->name;
}
```
Check [this link](http://wordpress.org/support/topic/wp_get_post_categories-equivale... |
143,263 | <p>I've this code:</p>
<pre><code>/* Hook to admin_menu the yasr_add_pages function above */
add_action('admin_menu', 'yasr_add_pages');
function yasr_add_pages()
{
//Add Settings Page
add_options_page(
'Yet Another Stars Rating: Settings', //Page Title
__('Yet Another Stars Rating: Setti... | [
{
"answer_id": 143282,
"author": "Nick Young",
"author_id": 48502,
"author_profile": "https://wordpress.stackexchange.com/users/48502",
"pm_score": 0,
"selected": false,
"text": "<p>So the problem here isn't actually anything to do with the way you are registering settings or outputting ... | 2014/05/03 | [
"https://wordpress.stackexchange.com/questions/143263",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48442/"
] | I've this code:
```
/* Hook to admin_menu the yasr_add_pages function above */
add_action('admin_menu', 'yasr_add_pages');
function yasr_add_pages()
{
//Add Settings Page
add_options_page(
'Yet Another Stars Rating: Settings', //Page Title
__('Yet Another Stars Rating: Settings', 'yasr')... | From what I see, you are mixing output and the code, which is meant to prepare that output. More, the preparation is coming after the output started. Looks weird to me.
Here I updated your code, and it works OK:
```
/* Hook to admin_menu the yasr_add_pages function above */
add_action( 'admin_menu', 'yasr_add_pages' ... |
143,297 | <p>I'm trying to execute a PHP script which is located in home directory of WordPress.</p>
<p>For example <strong>run.php</strong></p>
<pre><code><?php echo 'i run'; ?>
</code></pre>
<p>I want to run this page in URL <code>mysite.com/run.php</code> but it says 404 not found, even the <code>run.php</code> is lo... | [
{
"answer_id": 258169,
"author": "Thilak",
"author_id": 113208,
"author_profile": "https://wordpress.stackexchange.com/users/113208",
"pm_score": 2,
"selected": false,
"text": "<p>If you want to add custom page in WordPress, you need to add your custom PHP file into currently activated ... | 2014/05/03 | [
"https://wordpress.stackexchange.com/questions/143297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm trying to execute a PHP script which is located in home directory of WordPress.
For example **run.php**
```
<?php echo 'i run'; ?>
```
I want to run this page in URL `mysite.com/run.php` but it says 404 not found, even the `run.php` is located in that address.
What am I doing wrong? | If you want to add custom page in WordPress, you need to add your custom PHP file into currently activated theme ( */wp-content/themes/* ) folder.
Suppose you have child-theme. Put the file to child-theme folder. Then goto page section, Click **Add New**.
In Page Attributes, Choose Template as your PHP File.
Open th... |
143,302 | <p>I have a plugin with a line calling wp_capabilities. This works with the default prefix. If someone changes the prefix to something else (bluehost scripts do this), how do I fix this code? Can you also explain why?</p>
<p>I can hard code it for the individual site but how do I make it 'universal'?</p>
<p>Change:</... | [
{
"answer_id": 143312,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 1,
"selected": false,
"text": "<p>The prefix refers <strong>only</strong> to the database tables prefix, other uses of the <code>wp_</code... | 2014/05/04 | [
"https://wordpress.stackexchange.com/questions/143302",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47326/"
] | I have a plugin with a line calling wp\_capabilities. This works with the default prefix. If someone changes the prefix to something else (bluehost scripts do this), how do I fix this code? Can you also explain why?
I can hard code it for the individual site but how do I make it 'universal'?
Change:
```
$current_use... | The prefix refers **only** to the database tables prefix, other uses of the `wp_` prefix in function, class, variable, (array) index or (class) property names are entirely unaffected and remain as `wp_`.
As such, so long as all plug-ins (and themes) you use avoid using SQL statements with a hardcoded `wp_` prefix (and... |
143,321 | <p>What is the argument to pass to switch theme, when I have the result of <code>wp_get_themes()</code>?</p>
<pre><code> $args = array(
'allowed' => true
);
$themes = wp_get_themes( );
foreach ($themes as $theme) {
$argument_to_pass_to_switch_theme = ??????
}
</code></pre>
| [
{
"answer_id": 143312,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 1,
"selected": false,
"text": "<p>The prefix refers <strong>only</strong> to the database tables prefix, other uses of the <code>wp_</code... | 2014/05/04 | [
"https://wordpress.stackexchange.com/questions/143321",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47664/"
] | What is the argument to pass to switch theme, when I have the result of `wp_get_themes()`?
```
$args = array(
'allowed' => true
);
$themes = wp_get_themes( );
foreach ($themes as $theme) {
$argument_to_pass_to_switch_theme = ??????
}
``` | The prefix refers **only** to the database tables prefix, other uses of the `wp_` prefix in function, class, variable, (array) index or (class) property names are entirely unaffected and remain as `wp_`.
As such, so long as all plug-ins (and themes) you use avoid using SQL statements with a hardcoded `wp_` prefix (and... |
143,352 | <p>I have the following code (created very kindly by alchemyth in response to a question I posted on the WordPress.org forum <a href="https://wordpress.org/support/topic/display-multiple-pages-on-one-page?replies=6#post-5534924" rel="nofollow">here</a>) that I hope to use to display lots of pages on a single page: </p>... | [
{
"answer_id": 143353,
"author": "Douglas.Sesar",
"author_id": 19945,
"author_profile": "https://wordpress.stackexchange.com/users/19945",
"pm_score": 3,
"selected": true,
"text": "<p>Take a look at <a href=\"http://codex.wordpress.org/Page_Templates\" rel=\"nofollow\">Wordpress Page Tem... | 2014/05/04 | [
"https://wordpress.stackexchange.com/questions/143352",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51090/"
] | I have the following code (created very kindly by alchemyth in response to a question I posted on the WordPress.org forum [here](https://wordpress.org/support/topic/display-multiple-pages-on-one-page?replies=6#post-5534924)) that I hope to use to display lots of pages on a single page:
```
<?php
$args = array(
'pos... | Take a look at [Wordpress Page Templates](http://codex.wordpress.org/Page_Templates);
You can create a file with structure to match your current theme and place your code in the content area ( or place an action hook for your special content ).
Example for Twenty Twelve:
```
/*
Template Name: My Custom Page
*/
get_... |
143,354 | <p>I have a multi site setup to which I have placed </p>
<pre><code>define( 'NOBLOGREDIRECT', 'http://www.example.com' );
</code></pre>
<p>In the wp-config.php file</p>
<p>However when I visit a site which dose not exist (e.g. <a href="http://nosite.example.com" rel="nofollow">http://nosite.example.com</a>) I'm gree... | [
{
"answer_id": 143353,
"author": "Douglas.Sesar",
"author_id": 19945,
"author_profile": "https://wordpress.stackexchange.com/users/19945",
"pm_score": 3,
"selected": true,
"text": "<p>Take a look at <a href=\"http://codex.wordpress.org/Page_Templates\" rel=\"nofollow\">Wordpress Page Tem... | 2014/05/04 | [
"https://wordpress.stackexchange.com/questions/143354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17073/"
] | I have a multi site setup to which I have placed
```
define( 'NOBLOGREDIRECT', 'http://www.example.com' );
```
In the wp-config.php file
However when I visit a site which dose not exist (e.g. <http://nosite.example.com>) I'm greeted with the following
>
> Error establishing a database connection
>
>
>
Instea... | Take a look at [Wordpress Page Templates](http://codex.wordpress.org/Page_Templates);
You can create a file with structure to match your current theme and place your code in the content area ( or place an action hook for your special content ).
Example for Twenty Twelve:
```
/*
Template Name: My Custom Page
*/
get_... |
143,358 | <p>I'm trying to add a xProfile to BuddyPress, but I don't know where but my snippet is not working. I have tried so many stuff, but I just can't get it right.</p>
<p>Hope you can help, here's the latest version of my snippet:</p>
<pre><code>add_action('bp_init', 'field_xprofile_twitter');
function field_xprofile_tw... | [
{
"answer_id": 158837,
"author": "Carlos",
"author_id": 58618,
"author_profile": "https://wordpress.stackexchange.com/users/58618",
"pm_score": 3,
"selected": true,
"text": "<p>Your code does work. It's just that you are declaring $xfield_args after you have made the call xprofile_insert... | 2014/05/04 | [
"https://wordpress.stackexchange.com/questions/143358",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33233/"
] | I'm trying to add a xProfile to BuddyPress, but I don't know where but my snippet is not working. I have tried so many stuff, but I just can't get it right.
Hope you can help, here's the latest version of my snippet:
```
add_action('bp_init', 'field_xprofile_twitter');
function field_xprofile_twitter()
{
xprofile_i... | Your code does work. It's just that you are declaring $xfield\_args after you have made the call xprofile\_insert\_field( $xfield\_args );
it should look like this
```
add_action('bp_init', 'field_xprofile_twitter');
function field_xprofile_twitter()
{
global $bp;
$xfield_args = array (
field_gro... |
143,364 | <p>I'm attempting to get this function to work and it seems to not work when put together.
When I just have </p>
<pre><code> $new_status == 'publish'
</code></pre>
<p>it works, when I use just the second it also works. When I attempt to && them together there seems to be a hiccup. </p>
<p>Also it should be... | [
{
"answer_id": 143365,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 3,
"selected": true,
"text": "<p>Your original function relies on the <code>$_POST['post_type']</code> being set to the appropriate value.... | 2014/05/04 | [
"https://wordpress.stackexchange.com/questions/143364",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44745/"
] | I'm attempting to get this function to work and it seems to not work when put together.
When I just have
```
$new_status == 'publish'
```
it works, when I use just the second it also works. When I attempt to && them together there seems to be a hiccup.
Also it should be noted that I attempted just to use the
... | Your original function relies on the `$_POST['post_type']` being set to the appropriate value. As a general rule, you should avoid using global variables - if you use only want the function gives to you, you don't have to think about the contexts in what it should be called.
In this case, that's what's happened. You'r... |
143,376 | <p>I have created one menu and have some sub-menu but I don't want to display any sub-menu from my template.</p>
<p>My Menu code:</p>
<pre><code><?php wp_nav_menu( array('menu' => 'header-uk', 'menu_id' => 'nav', 'menu_class' => 'sitemap', 'fallback_cb' => false) ); ?>
</code></pre>
<p>My Menu Scre... | [
{
"answer_id": 143377,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 0,
"selected": false,
"text": "<p>It's a CSS trick, not related to WordPress I guess. BTW you can do something like this:</p>\n\n<pre><c... | 2014/05/05 | [
"https://wordpress.stackexchange.com/questions/143376",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44300/"
] | I have created one menu and have some sub-menu but I don't want to display any sub-menu from my template.
My Menu code:
```
<?php wp_nav_menu( array('menu' => 'header-uk', 'menu_id' => 'nav', 'menu_class' => 'sitemap', 'fallback_cb' => false) ); ?>
```
My Menu Screenshot:
 );
```
Or if what you want to do is grab all items to create your own loop/output you can do that as w... |
143,388 | <p>I'm trying to add the <code>rel="canonical"</code> tag to only one page, the home page. In order to add the tag, I need to add it to the <code><head></code> part of the template, in the header.php file. This will add the same rel canonical tag to all the pages of my wordpress website.</p>
<p>How can I add rel... | [
{
"answer_id": 143390,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Check if you are on the front page with <code>is_front_page()</code>. The <em>home</em> page (in WordPress the page w... | 2014/05/05 | [
"https://wordpress.stackexchange.com/questions/143388",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51239/"
] | I'm trying to add the `rel="canonical"` tag to only one page, the home page. In order to add the tag, I need to add it to the `<head>` part of the template, in the header.php file. This will add the same rel canonical tag to all the pages of my wordpress website.
How can I add rel canonical to only one page, the home ... | Check if you are on the front page with `is_front_page()`. The *home* page (in WordPress the page with the latest posts) can be checked with `is_home()`.
You can add this to the `header.php` between `<head>` and `</head>`:
```
<?php
if ( is_front_page() )
echo '<link rel="canonical" href="' . home_url( '/' ) . '"... |
143,402 | <p>I hope someone can help out with this as it is very frustrating...</p>
<p>I am trying to build a property site in Wordpress and would like to link two custom post types together - </p>
<p>One would be development areas and the other would be individual properties within that development area</p>
<p>I understand t... | [
{
"answer_id": 143404,
"author": "MikO",
"author_id": 48313,
"author_profile": "https://wordpress.stackexchange.com/users/48313",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the fantastic and free <strong><a href=\"http://www.advancedcustomfields.com/\" rel=\"nofollow\">Adv... | 2014/05/05 | [
"https://wordpress.stackexchange.com/questions/143402",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51248/"
] | I hope someone can help out with this as it is very frustrating...
I am trying to build a property site in Wordpress and would like to link two custom post types together -
One would be development areas and the other would be individual properties within that development area
I understand that I can create a CPT c... | If I understand what you are doing, you are looking to set up a one to many relationship between development areas and properties.
Here is a class that, if loaded and then instantiated, will:
* create a meta box for a post type named development\_area which contains a check box list of all available properties so tha... |
143,405 | <p>When i try something like this</p>
<pre><code> $status = NULL;
$wpdb->update(
'table',
array(
'status' => $status,
),
array( 'id' => 1 )
);
</code></pre>
<p>In the 'status' column now i have an empty string <code>''</code>, it ... | [
{
"answer_id": 143418,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 5,
"selected": true,
"text": "<h2>Update:</h2>\n\n<p>Since WordPress 4.4. this is now supported by the <code>insert</code>, <code>update</code>... | 2014/05/05 | [
"https://wordpress.stackexchange.com/questions/143405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30817/"
] | When i try something like this
```
$status = NULL;
$wpdb->update(
'table',
array(
'status' => $status,
),
array( 'id' => 1 )
);
```
In the 'status' column now i have an empty string `''`, it simply won't set it to NULL.
The column can b... | Update:
-------
Since WordPress 4.4. this is now supported by the `insert`, `update`, `replace` and `delete` methods of `wpdb` and the ticket [#15158](https://core.trac.wordpress.org/ticket/15158) has been closed as *fixed*.
Thanks to @dmsnell for [commenting](https://wordpress.stackexchange.com/questions/143405/wpd... |
143,410 | <p>When I try to send mail... it showing - </p>
<blockquote>
<p>Fatal error: Call to undefined function get_option() in
/home/junkie/public_html/sub_demo/wp-content/themes/scroller/includes/contact-form.php
on line 9</p>
</blockquote>
<p>My code=> contact-form.php </p>
<pre><code><?php
if($_POST)
{
//ch... | [
{
"answer_id": 143412,
"author": "Petr Cibulka",
"author_id": 28718,
"author_profile": "https://wordpress.stackexchange.com/users/28718",
"pm_score": 1,
"selected": false,
"text": "<p>I don't see any <code>get_option()</code> function on line 9 or anywhere else in your code.</p>\n\n<p>Af... | 2014/05/05 | [
"https://wordpress.stackexchange.com/questions/143410",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50868/"
] | When I try to send mail... it showing -
>
> Fatal error: Call to undefined function get\_option() in
> /home/junkie/public\_html/sub\_demo/wp-content/themes/scroller/includes/contact-form.php
> on line 9
>
>
>
My code=> contact-form.php
```
<?php
if($_POST)
{
//check if its an ajax request, exit if not
... | I don't see any `get_option()` function on line 9 or anywhere else in your code.
After quick googling, my guess would be that your problem is the same as [this question on stackoverflow](https://stackoverflow.com/questions/19326761/wordpress-php-fatal-error-call-to-undefined-function-get-option)
EDIT
----
As @Ray pr... |
143,444 | <p>I am attempting to get the title displayed for a function. I am sending myself an email to see if I can get this to work for different titles. Currently the only way I can get it to work is via hard coded number inside the get_the_title. my example below works. </p>
<pre><code>$tweetingthing = get_the_title(1067); ... | [
{
"answer_id": 152585,
"author": "Carl",
"author_id": 55095,
"author_profile": "https://wordpress.stackexchange.com/users/55095",
"pm_score": -1,
"selected": true,
"text": "<p>You can grab some ideas from this tutorial:</p>\n\n<p><a href=\"http://carlofontanos.com/auto-login-to-wordpress... | 2014/05/05 | [
"https://wordpress.stackexchange.com/questions/143444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44745/"
] | I am attempting to get the title displayed for a function. I am sending myself an email to see if I can get this to work for different titles. Currently the only way I can get it to work is via hard coded number inside the get\_the\_title. my example below works.
```
$tweetingthing = get_the_title(1067);
$to ... | You can grab some ideas from this tutorial:
<http://carlofontanos.com/auto-login-to-wordpress-from-another-website/>
hope it helps. |
143,467 | <p>So I am planning a theme that will depend on a plugin (for instance <a href="https://github.com/jarednova/timber/" rel="nofollow">Timber</a> or <a href="https://github.com/themosis/themosis" rel="nofollow">Themosis</a>).
So of course a theme will break if it can't use it's depending plugin's. So I would like a way ... | [
{
"answer_id": 143469,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know how to prevent the theme switch (though there may well be a way), however I can think of a work... | 2014/05/05 | [
"https://wordpress.stackexchange.com/questions/143467",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51262/"
] | So I am planning a theme that will depend on a plugin (for instance [Timber](https://github.com/jarednova/timber/) or [Themosis](https://github.com/themosis/themosis)).
So of course a theme will break if it can't use it's depending plugin's. So I would like a way to stop the user of activating a theme that needs a cer... | Using `after_switch_theme` will activate the theme (which is fine as we want to run the check within the context of the new theme).
If the dependencies are not fulfilled (`$missing_dependencies = true;`) we're instantly switching back to the theme previously used (passed via `after_switch_theme` and `$oldtheme`).
```... |
143,477 | <p>I want the native WordPress search input to search metadata in addition to its standard title and content search, however setting a <code>meta_query</code> adds an <code>AND</code> clause to the request when what I need is an <code>OR</code>.</p>
<p>My function:</p>
<pre><code>function search_faqs_metadata($query)... | [
{
"answer_id": 143590,
"author": "cfx",
"author_id": 28957,
"author_profile": "https://wordpress.stackexchange.com/users/28957",
"pm_score": 3,
"selected": true,
"text": "<p>I believe the shortest and best approach is to (1) modify the query:</p>\n\n<pre><code>function search_faqs_metada... | 2014/05/06 | [
"https://wordpress.stackexchange.com/questions/143477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28957/"
] | I want the native WordPress search input to search metadata in addition to its standard title and content search, however setting a `meta_query` adds an `AND` clause to the request when what I need is an `OR`.
My function:
```
function search_faqs_metadata($query) {
if(!is_admin() && $query->is_main_query()) {
... | I believe the shortest and best approach is to (1) modify the query:
```
function search_faqs_metadata($query) {
if(!is_admin() && $query->is_main_query()) {
if($query->is_search) {
$query->set('meta_query', array(array(
'key' => '_faqs',
'value' => $query->query_vars['s'],
'compare... |
143,489 | <p>Maybe there's a better way to do this. Let me explain what I have right now:</p>
<p>I have a custom post type (Products), and a custom taxonomy (Manufacturers).</p>
<p>What I have outputting so far:</p>
<pre><code>Manufacturer Name 1
Product 1
Product 2
Product 3
Manufacturer Name 2
Product 1
Product 2
Product 3... | [
{
"answer_id": 143590,
"author": "cfx",
"author_id": 28957,
"author_profile": "https://wordpress.stackexchange.com/users/28957",
"pm_score": 3,
"selected": true,
"text": "<p>I believe the shortest and best approach is to (1) modify the query:</p>\n\n<pre><code>function search_faqs_metada... | 2014/05/06 | [
"https://wordpress.stackexchange.com/questions/143489",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51270/"
] | Maybe there's a better way to do this. Let me explain what I have right now:
I have a custom post type (Products), and a custom taxonomy (Manufacturers).
What I have outputting so far:
```
Manufacturer Name 1
Product 1
Product 2
Product 3
Manufacturer Name 2
Product 1
Product 2
Product 3
```
This is great, except... | I believe the shortest and best approach is to (1) modify the query:
```
function search_faqs_metadata($query) {
if(!is_admin() && $query->is_main_query()) {
if($query->is_search) {
$query->set('meta_query', array(array(
'key' => '_faqs',
'value' => $query->query_vars['s'],
'compare... |
143,496 | <p>when i save a data with my curl function using hook to save a data twice.</p>
<pre><code>public function __construct() {
add_action('init', array(&$this, 'init'));
add_action('admin_init', array(&$this, 'admin_init'));
add_action('admin_menu', array(&$this, 'add_page'... | [
{
"answer_id": 143517,
"author": "Ravi Patel",
"author_id": 35477,
"author_profile": "https://wordpress.stackexchange.com/users/35477",
"pm_score": -1,
"selected": true,
"text": "<p><a href=\"http://cmsblogheart.wordpress.com/2014/05/09/post-save-twice-during-use-hook-add_actionsave_post... | 2014/05/06 | [
"https://wordpress.stackexchange.com/questions/143496",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35477/"
] | when i save a data with my curl function using hook to save a data twice.
```
public function __construct() {
add_action('init', array(&$this, 'init'));
add_action('admin_init', array(&$this, 'admin_init'));
add_action('admin_menu', array(&$this, 'add_page'));
add_action... | [More info this code](http://cmsblogheart.wordpress.com/2014/05/09/post-save-twice-during-use-hook-add_actionsave_post/)
```
<?php
global $my_save_post_flag;
// .. some stuff here ..
if ($my_save_post_flag == 0) {
// .. do the stuff only onc... |
143,503 | <p>I want to resize images on server, I have more than 7000 images in library of my WordPress site. I want to resize all images on server itself. I know that regenerate thumbnails plugin can be used, but for that I will have to keep my browser window open all the day and it can even crash somewhere in middle that will ... | [
{
"answer_id": 143506,
"author": "Selva Balaji",
"author_id": 25011,
"author_profile": "https://wordpress.stackexchange.com/users/25011",
"pm_score": 0,
"selected": false,
"text": "<p>Bulk Resize Media automatically resizes huge image uploads and makes sure the maximum upload size is res... | 2014/05/06 | [
"https://wordpress.stackexchange.com/questions/143503",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51280/"
] | I want to resize images on server, I have more than 7000 images in library of my WordPress site. I want to resize all images on server itself. I know that regenerate thumbnails plugin can be used, but for that I will have to keep my browser window open all the day and it can even crash somewhere in middle that will lea... | Ankit
you can re-size images by using this script via terminal:
```
<?php
ini_set('max_execution_time', 0);
set_time_limit(0);
require_once('./wp-load.php');
require_once( './wp-admin/includes/admin.php' );
for($i=0;$i<=500;$i++){
$attachments =& get_children(array(
'post_type' => 'attachment',
'p... |
143,552 | <p>I've read here and other places about setting a post's title based on it's metadata. Unfortunately I'm unable to get it working and I'm hoping someone else can point me in the proper direction or explain where I'm wrong. Here's my code:</p>
<pre><code>function setup_match_title( $data, $postarr ) {
if ( $data['... | [
{
"answer_id": 143554,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>As soon as you hit \"Add New\" and the new post pages starts to load, WordPress inserts a mostly blank post ... | 2014/05/06 | [
"https://wordpress.stackexchange.com/questions/143552",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14194/"
] | I've read here and other places about setting a post's title based on it's metadata. Unfortunately I'm unable to get it working and I'm hoping someone else can point me in the proper direction or explain where I'm wrong. Here's my code:
```
function setup_match_title( $data, $postarr ) {
if ( $data['post_type'] ==... | For whatever reason `get_post_meta()` wasn't working when run inside the `wp_insert_post_data()` filter. However, after doing a `var_dump( $postarr )` I saw that the meta keys were being populated with the expected values.
I simply replaced the `get_post_meta()` function lines w/ the following:
```
$a = isset( $posta... |