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
65,437
<p>When working with a worpress site with lots of custom post types and lots of page templates, my theme folder is looking messy. What are the accepted best practices to organise code files in WordPress?</p> <p>a couple of the limitations i'm coming up against are that templates are chosen by name, so i can't group fi...
[ { "answer_id": 65440, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": true, "text": "<p>Not a full answer, but I can at least answer this question:</p>\n\n<blockquote>\n <p>Also custom post template file...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65437", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19935/" ]
When working with a worpress site with lots of custom post types and lots of page templates, my theme folder is looking messy. What are the accepted best practices to organise code files in WordPress? a couple of the limitations i'm coming up against are that templates are chosen by name, so i can't group files by pre...
Not a full answer, but I can at least answer this question: > > Also custom post template files can not be in sub directories. > > > Everything, that you can load via `get_template_part()`, can reside in a subfolder: ``` get_template_part( 'subdir/part', 'suffix' ); ``` It's as easy as that. Now you've your pa...
65,450
<p>I'm not trying to navigate to the next post within a category, but to put previous category and next category under the category description on its archive page and navigate between archive pages.</p> <p>I've searched, but I'm not sure this is even possible without hardcoding categories, and I don't want to do that...
[ { "answer_id": 65539, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>As often, the answer depends on your </p>\n\n<pre><code>$permalinks = get_option( 'permalink_structure' )\n</code><...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65450", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20348/" ]
I'm not trying to navigate to the next post within a category, but to put previous category and next category under the category description on its archive page and navigate between archive pages. I've searched, but I'm not sure this is even possible without hardcoding categories, and I don't want to do that. I'd like...
Not sure if this is what you want, gets all the categories and outputs a link to the next and previous in the order returned from `get_categories()`: ``` $this_category = get_queried_object(); $categories = get_categories(); foreach( $categories as $position => $cat ) : if( $this_category->term_id == $cat->term_i...
65,459
<p>i need to get my clients website online and have been able to figure everything out except of course the most crucial part which is the database upload. i can't figure out what i'm doing wrong since every tutorial and forum i've been on has basically told me to do the same things and still i get errors. i'm missing ...
[ { "answer_id": 65460, "author": "Lalit Kaushik", "author_id": 20389, "author_profile": "https://wordpress.stackexchange.com/users/20389", "pm_score": 1, "selected": false, "text": "<p>99.99% chance that you configure wordpress with wrong database details.</p>\n\n<p>make sure you are usin...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65459", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20356/" ]
i need to get my clients website online and have been able to figure everything out except of course the most crucial part which is the database upload. i can't figure out what i'm doing wrong since every tutorial and forum i've been on has basically told me to do the same things and still i get errors. i'm missing a c...
99.99% chance that you configure wordpress with wrong database details. make sure you are using correct database details in wp-config.php file ``` /** The name of the database for WordPress */ define('DB_NAME', 'database_name_here'); /** MySQL database username */ define('DB_USER', 'username_here'); /** MySQL datab...
65,465
<p>Because of the way my templates are structured, I need to pull the first/sticky post from the site outside of the standard loop, just on the homepage. I'm using _s (underscores.me) as a base, so the current loop on the index look like this:</p> <pre><code> &lt;?php if ( have_posts() ) : ?&gt; &lt;?php /* Star...
[ { "answer_id": 65460, "author": "Lalit Kaushik", "author_id": 20389, "author_profile": "https://wordpress.stackexchange.com/users/20389", "pm_score": 1, "selected": false, "text": "<p>99.99% chance that you configure wordpress with wrong database details.</p>\n\n<p>make sure you are usin...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65465", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20532/" ]
Because of the way my templates are structured, I need to pull the first/sticky post from the site outside of the standard loop, just on the homepage. I'm using \_s (underscores.me) as a base, so the current loop on the index look like this: ``` <?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?p...
99.99% chance that you configure wordpress with wrong database details. make sure you are using correct database details in wp-config.php file ``` /** The name of the database for WordPress */ define('DB_NAME', 'database_name_here'); /** MySQL database username */ define('DB_USER', 'username_here'); /** MySQL datab...
65,494
<p>In a custom post type, is there a way to include the "order" field that is available for pages?</p> <p>Is there any built-in logic that prevents duplicate values in the "order" field?</p> <p>The idea is to be able to sort a custom post type by a user-specified order, then alphabetically by a string-based custom fi...
[ { "answer_id": 65497, "author": "Dave Hunt", "author_id": 1769, "author_profile": "https://wordpress.stackexchange.com/users/1769", "pm_score": 6, "selected": true, "text": "<p>When declaring your custom post type using the register_post_type function, you have to add 'page-attributes' t...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65494", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7332/" ]
In a custom post type, is there a way to include the "order" field that is available for pages? Is there any built-in logic that prevents duplicate values in the "order" field? The idea is to be able to sort a custom post type by a user-specified order, then alphabetically by a string-based custom field.
When declaring your custom post type using the register\_post\_type function, you have to add 'page-attributes' to the support field, like in the following example: ``` register_post_type('myposttype', array( 'supports' => array('title', 'editor', 'page-attributes'), 'hierarchical' => false )); ``` You'll ne...
65,499
<p>I have a country taxonomy with children taxonomies > state &amp; city. </p> <p>For a given entry for a restaurant in Nantucket, I want it to say "Nantucket, Massachusetts, United States (each linked to those taxonomy pages)", but the code I have gotten to work (I'm new to PHP) outputs: </p> <p>Massachusetts, Nant...
[ { "answer_id": 65517, "author": "marfarma", "author_id": 4645, "author_profile": "https://wordpress.stackexchange.com/users/4645", "pm_score": 2, "selected": false, "text": "<p>To expand on my comment above, you would replace your code with something like this:</p>\n\n<pre><code>print_ta...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65499", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20546/" ]
I have a country taxonomy with children taxonomies > state & city. For a given entry for a restaurant in Nantucket, I want it to say "Nantucket, Massachusetts, United States (each linked to those taxonomy pages)", but the code I have gotten to work (I'm new to PHP) outputs: Massachusetts, Nantucket, United States ...
To expand on my comment above, you would replace your code with something like this: ``` print_taxonomy_ranks( get_the_terms( $post->ID, 'post_tags' ) ); ``` and in your function `print_taxonomy_ranks` you'd replace the echo statement with your preferred output. ``` function print_taxonomy_ranks( $terms ) { // if t...
65,502
<p>Hi I am following the instructions from <a href="http://css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/" rel="nofollow">this article</a> and I cannot get it to work, it gives me a blank screen.</p> <p>I think there is something wrong with the opening and closing php tags between the div "view vie...
[ { "answer_id": 65505, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": -1, "selected": false, "text": "<p>I doubt there is anything wrong with the code bit - but please note that <code>get_the_post_thumbnail</co...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65502", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17112/" ]
Hi I am following the instructions from [this article](http://css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/) and I cannot get it to work, it gives me a blank screen. I think there is something wrong with the opening and closing php tags between the div "view view-first" and the div "mask". When I ...
Chris's article looks for the img tag on your post. Since you are using WordPress, and I'm assuming the WordPress uploads feature, here is how you can get the first uploaded image on your post. Paste the following code in your theme's functions.php file. ``` //function to call first uploaded image in functions file fu...
65,503
<p>I've been looking for an answer for a couple of days now. I've tried every snippet possible, changing the functions files, creating a separate template for content products but I can't change the number of products listed. Currently WooCommerce displays 4 products per row. Adding a css class of "last" to that fourth...
[ { "answer_id": 65530, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>You didn't say what snippets you've actually tried, but according to the docs, you can filter <a href=\"http://wcdo...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65503", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17913/" ]
I've been looking for an answer for a couple of days now. I've tried every snippet possible, changing the functions files, creating a separate template for content products but I can't change the number of products listed. Currently WooCommerce displays 4 products per row. Adding a css class of "last" to that fourth pr...
You didn't say what snippets you've actually tried, but according to the docs, you can filter [`loop_shop_columns`](http://wcdocs.woothemes.com/codex/extending/hooks/) like so: ``` function wpa65503_woo_shop_columns( $columns ) { return 3; } add_filter( 'loop_shop_columns', 'wpa65503_woo_shop_columns' ); ``` tes...
65,509
<p>We recently launched a new site that has a different permalink stucture than its prior one.</p> <p>Old site URL was like this:<br /> <a href="http://centerline.net/blog/detail/?p=3989" rel="nofollow">http://centerline.net/blog/detail/?p=3989</a> </p> <p>New like this:<br /> <a href="http://centerline.net/cxo-conte...
[ { "answer_id": 65530, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>You didn't say what snippets you've actually tried, but according to the docs, you can filter <a href=\"http://wcdo...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10692/" ]
We recently launched a new site that has a different permalink stucture than its prior one. Old site URL was like this: <http://centerline.net/blog/detail/?p=3989> New like this: <http://centerline.net/cxo-content-conversations-part-1-is-your-content-lacking-eminence/> Simply setting up a 301 redirect doesn't...
You didn't say what snippets you've actually tried, but according to the docs, you can filter [`loop_shop_columns`](http://wcdocs.woothemes.com/codex/extending/hooks/) like so: ``` function wpa65503_woo_shop_columns( $columns ) { return 3; } add_filter( 'loop_shop_columns', 'wpa65503_woo_shop_columns' ); ``` tes...
65,518
<p>I simply want to add some php in as a custom link in the wordpress menu section. The code I want to use is <code>&lt;?php bp_loggedin_user_domain(); ?&gt;</code> which will generate that logged in user's buddypress profile page url. However, when I paste that in as a custom links, wp removes the opening and closin...
[ { "answer_id": 65524, "author": "Martin Hasan", "author_id": 17913, "author_profile": "https://wordpress.stackexchange.com/users/17913", "pm_score": 2, "selected": false, "text": "<p>You could do something like this:</p>\n\n<pre><code>&lt;?php\nif ( is_user_logged_in() ) {\n wp_nav_m...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65518", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14739/" ]
I simply want to add some php in as a custom link in the wordpress menu section. The code I want to use is `<?php bp_loggedin_user_domain(); ?>` which will generate that logged in user's buddypress profile page url. However, when I paste that in as a custom links, wp removes the opening and closing tags and removes all...
You could do something like this: ``` <?php if ( is_user_logged_in() ) { wp_nav_menu( array( 'theme_location' => 'logged-in-menu' ) ); } else { wp_nav_menu( array( 'theme_location' => 'logged-out-menu' ) ); } ?> ``` **EDIT:** Here is another try, same theory but different execution: ``` if ( is_user_logg...
65,523
<p>My parent theme (Starkers) adds a CSS file that I'm trying to remove (I want to use @import instead so I can override styles more easily). Starkers has the following in its functions.php:</p> <pre><code>add_action( 'wp_enqueue_scripts', 'script_enqueuer' ); function script_enqueuer() { wp_register_script( 'sit...
[ { "answer_id": 65526, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 7, "selected": true, "text": "<blockquote>\n <p>I want to use @import instead so I can override styles more easily</p>\n</blockquote>\n\n<p>Simply. ...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65523", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20551/" ]
My parent theme (Starkers) adds a CSS file that I'm trying to remove (I want to use @import instead so I can override styles more easily). Starkers has the following in its functions.php: ``` add_action( 'wp_enqueue_scripts', 'script_enqueuer' ); function script_enqueuer() { wp_register_script( 'site', get_templa...
> > I want to use @import instead so I can override styles more easily > > > Simply. Don't. Do. That. You simply jump into the same hook and then deregister/dequeue the styles/scripts and throw in your custom ones. ``` function PREFIX_remove_scripts() { wp_dequeue_style( 'screen' ); wp_deregister_style( ...
65,531
<p>I have this funny problem and I'm not able to locate where it happens.<br> The problem is when a user registers on my site his/her registration date is wrong (not just wrong but total rubbish, even if I add them manually from the admin panel).<br> I tried deactivating every plugin and theme installed on wordpress to...
[ { "answer_id": 65526, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 7, "selected": true, "text": "<blockquote>\n <p>I want to use @import instead so I can override styles more easily</p>\n</blockquote>\n\n<p>Simply. ...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65531", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7410/" ]
I have this funny problem and I'm not able to locate where it happens. The problem is when a user registers on my site his/her registration date is wrong (not just wrong but total rubbish, even if I add them manually from the admin panel). I tried deactivating every plugin and theme installed on wordpress to no a...
> > I want to use @import instead so I can override styles more easily > > > Simply. Don't. Do. That. You simply jump into the same hook and then deregister/dequeue the styles/scripts and throw in your custom ones. ``` function PREFIX_remove_scripts() { wp_dequeue_style( 'screen' ); wp_deregister_style( ...
65,546
<p>My WordPress website currently uses this custom permalink structure: %author%/%year%/%monthnum%/%day%/%postname%</p> <p>In this case, %monthnum% instantiates numbered dates with a leading zero -- e.g., "09" for September. So, a sample URL might look like this:<br/> mywebsite.com/username/2012/09/12/post-name</p> <...
[ { "answer_id": 65550, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>Filter <code>'month_link'</code> and <code>'day_link'</code>, WordPress will find the matching posts then without furt...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65546", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20567/" ]
My WordPress website currently uses this custom permalink structure: %author%/%year%/%monthnum%/%day%/%postname% In this case, %monthnum% instantiates numbered dates with a leading zero -- e.g., "09" for September. So, a sample URL might look like this: mywebsite.com/username/2012/09/12/post-name Is there a functi...
**How about using custom rewrite tags/structure?** So we'll be using these two [*rewrite/structure tags*](https://codex.wordpress.org/Using_Permalinks#Structure_Tags): 1. `%monthnum2%` does the same thing as the `%monthnum%` tag, but without a leading zero; e.g. `3` and not `03` for March. 2. `%day2%` does the same t...
65,548
<p>I can't get the post author ID outside the loop to make the get_the_author_meta work. So far I've tried different approaches:</p> <p>1.</p> <pre><code>$author_id=$post-&gt;post_author; </code></pre> <p>2.</p> <pre><code>global $post; $author_id=$post-&gt;post_author; </code></pre> <p>3.</p> <pre><code>$post_tm...
[ { "answer_id": 65564, "author": "Kuldeep Daftary", "author_id": 20241, "author_profile": "https://wordpress.stackexchange.com/users/20241", "pm_score": -1, "selected": false, "text": "<p>Why don't you use <a href=\"http://codex.wordpress.org/Function_Reference/the_author_meta\" rel=\"nof...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65548", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19797/" ]
I can't get the post author ID outside the loop to make the get\_the\_author\_meta work. So far I've tried different approaches: 1. ``` $author_id=$post->post_author; ``` 2. ``` global $post; $author_id=$post->post_author; ``` 3. ``` $post_tmp = get_post($post_id); $author_id = $post_tmp->post_author; ``` 4. ...
The simplest and most straightforward way to get the post author ID outside the loop, if you know the post ID, is to use the WordPress core function [`get_post_field()`](http://codex.wordpress.org/Function_Reference/get_post_field). ``` $post_author_id = get_post_field( 'post_author', $post_id ); ``` If you do not y...
65,569
<p>I have a WP site whose center column is variable width. </p> <p>I would like the featured image to appear front and center - 100% width. If I hard code the image path using a plain old image tag with width=100% it looks exactly as I want. </p> <p>For obvious reasons I don't want it hard coded.</p> <p>I'm curre...
[ { "answer_id": 65572, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p><code>get_the_post_thumbnail()</code> has multiple filters. Just make use of them from within your functions.php fi...
2012/09/18
[ "https://wordpress.stackexchange.com/questions/65569", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20573/" ]
I have a WP site whose center column is variable width. I would like the featured image to appear front and center - 100% width. If I hard code the image path using a plain old image tag with width=100% it looks exactly as I want. For obvious reasons I don't want it hard coded. I'm currently using this but the ima...
I ended up using the following to solve my problem. ``` <?php $image_id = get_post_thumbnail_id(); ?> <?php $image_attributes = wp_get_attachment_image_src( $image_id, 'full'); ?> <img src="<?php echo $image_attributes[0]; ?>" width="100%"> ```
65,585
<p>in a website that I am building I have a portfolio custom post types (called: "project") to show my portfolio items. The page that holds the loop of the custom post type is a custom page called "<strong>Portfolio</strong>" this page has only thumbnails and each thumbnail is linking to a custom post type: <a href="ht...
[ { "answer_id": 65587, "author": "mike23", "author_id": 1381, "author_profile": "https://wordpress.stackexchange.com/users/1381", "pm_score": 2, "selected": true, "text": "<p>You should be able to use a <em>body class</em> to style your menu item :</p>\n\n<pre><code>.single-project .menu-...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65585", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7730/" ]
in a website that I am building I have a portfolio custom post types (called: "project") to show my portfolio items. The page that holds the loop of the custom post type is a custom page called "**Portfolio**" this page has only thumbnails and each thumbnail is linking to a custom post type: <http://www.tipoos.com/new/...
You should be able to use a *body class* to style your menu item : ``` .single-project .menu-item-45 a ``` In "Appearance > Menu", you could also add custom CSS classes to menu items. You could give your Portfolio menu item a class of "portfolio" and do this : ``` .single-project .menu .portfolio a ``` I do this ...
65,591
<p>I used webfonts in my Wordpress site. I need a rewriterule in my htacces. I put this in my htacces file:</p> <pre><code>RewriteRule ^fonts/(.*) /mikevierwind/wp-content/themes/roots/fonts/$1 [QSA,L] </code></pre> <p>But when i save this htacces file. Wordpress is rewriting the htacces file and my fonts rewriterule...
[ { "answer_id": 65587, "author": "mike23", "author_id": 1381, "author_profile": "https://wordpress.stackexchange.com/users/1381", "pm_score": 2, "selected": true, "text": "<p>You should be able to use a <em>body class</em> to style your menu item :</p>\n\n<pre><code>.single-project .menu-...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65591", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17868/" ]
I used webfonts in my Wordpress site. I need a rewriterule in my htacces. I put this in my htacces file: ``` RewriteRule ^fonts/(.*) /mikevierwind/wp-content/themes/roots/fonts/$1 [QSA,L] ``` But when i save this htacces file. Wordpress is rewriting the htacces file and my fonts rewriterule is gone. How can i fix th...
You should be able to use a *body class* to style your menu item : ``` .single-project .menu-item-45 a ``` In "Appearance > Menu", you could also add custom CSS classes to menu items. You could give your Portfolio menu item a class of "portfolio" and do this : ``` .single-project .menu .portfolio a ``` I do this ...
65,597
<p>It seems if you use the wp_head hook as an action to put your custom metadata into the head tags of your page, it is dependent on where the theme you are using calls the wp_head. In my case, it is at the end of the head tags.</p> <p>How can I force my meta data near the top of the head tags? I have a header.php fil...
[ { "answer_id": 65601, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 1, "selected": false, "text": "<p>You can <a href=\"http://codex.wordpress.org/Function_Reference/do_action\" rel=\"nofollow\"><strong>create a cus...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65597", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19852/" ]
It seems if you use the wp\_head hook as an action to put your custom metadata into the head tags of your page, it is dependent on where the theme you are using calls the wp\_head. In my case, it is at the end of the head tags. How can I force my meta data near the top of the head tags? I have a header.php file I'm ca...
Okay, here's the answer: ``` function CustomHead() { include('headcontent.php'); } add_action('wp_head','CustomHead',1,1); ``` The key is that first "1", which sets the priority of it to run at the highest (this is an optional element, defaulting to 10, putting it at the end of the head by default). More info here: ...
65,602
<p>How do I use a plugin to put this inside the body of every page on my WP site, for facebook integration. (Yes, I know other plugins can do it, but I want to do it myself.) Facebook recommends as close to the top of the lead body tag as possible.</p> <p>Thanks!</p> <pre><code>&lt;script&gt;(function(d, s, id) { var...
[ { "answer_id": 65601, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 1, "selected": false, "text": "<p>You can <a href=\"http://codex.wordpress.org/Function_Reference/do_action\" rel=\"nofollow\"><strong>create a cus...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65602", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19852/" ]
How do I use a plugin to put this inside the body of every page on my WP site, for facebook integration. (Yes, I know other plugins can do it, but I want to do it myself.) Facebook recommends as close to the top of the lead body tag as possible. Thanks! ``` <script>(function(d, s, id) { var js, fjs = d.getElementsByT...
Okay, here's the answer: ``` function CustomHead() { include('headcontent.php'); } add_action('wp_head','CustomHead',1,1); ``` The key is that first "1", which sets the priority of it to run at the highest (this is an optional element, defaulting to 10, putting it at the end of the head by default). More info here: ...
65,607
<p>I am developing a social sharing widget. It has Facebook sharing option too. I wrote the following link structure for it but when clicked, the page neither displays the link to share, nor the title and decription. Please help out. Thanks</p> <pre><code>&lt;a href="http://www.facebook.com/sharer.php?u=&lt;?php get_p...
[ { "answer_id": 65610, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 0, "selected": false, "text": "<p>Try..</p>\n<pre><code>&lt;a href=&quot;http://www.facebook.com/sharer.php?u=\n&lt;?php echo get_permalink( $post-...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65607", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am developing a social sharing widget. It has Facebook sharing option too. I wrote the following link structure for it but when clicked, the page neither displays the link to share, nor the title and decription. Please help out. Thanks ``` <a href="http://www.facebook.com/sharer.php?u=<?php get_permalink();?>&t=<?ph...
You can try using this: ``` <?php $title = get_the_title( $post_id ); $url = urlencode( get_permalink( $post_id ) ); ?> <a class="fb" target="_blank" href="http://www.facebook.com/sharer.php?s=100&p[title]=<?php echo $title; ?>&p[url]=<?php echo $url; ?>">Share</a> ```
65,611
<p>I have a plugin which creates some options in wp_options, but also creates custom post types and is used to populate that post type. Upon install it makes sense to remove the data in wp_options, but with regards to the populated post type, there should be an option for the user to choose whether he wants to keep tha...
[ { "answer_id": 66141, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<pre><code>function wpse65611_confirm_uninstall()\n{\n ?&gt;\n &lt;form&gt;\n &lt;input type=\"button\" o...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65611", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
I have a plugin which creates some options in wp\_options, but also creates custom post types and is used to populate that post type. Upon install it makes sense to remove the data in wp\_options, but with regards to the populated post type, there should be an option for the user to choose whether he wants to keep that...
How about something similar to this: ``` function wpse65611_script() { wp_enqueue_style( 'wp-pointer' ); wp_enqueue_script( 'wp-pointer' ); wp_enqueue_script( 'utils' ); // for user settings ?> <script type="text/javascript"> jQuery('#embed-github-gist .delete a').click(function(){ jQue...
65,613
<p>How can I remove the hyperlink to posts on the edit.php screen when listing all posts?</p> <p>I am already removing the on hover links using the code below, but I want the actual post titles not to be hyperlinked at all.</p> <pre><code>add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 ); function remove_...
[ { "answer_id": 65629, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>All you're searching for is right inside <a href=\"https://github.com/WordPress/WordPress/blob/3.4.2/wp-admin/inclu...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65613", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
How can I remove the hyperlink to posts on the edit.php screen when listing all posts? I am already removing the on hover links using the code below, but I want the actual post titles not to be hyperlinked at all. ``` add_filter( 'post_row_actions', 'remove_row_actions', 10, 1 ); function remove_row_actions( $actions...
You can remove the a tag with javascript, short and easy. Use the follow plugin; include a small script in the footer of the `edit.php`, only this page in backend of WP and remove all a-tag inside the table; see the selector on the source below. ``` <?php /** * Plugin Name: Remove a * Version: 0.0.1 * Plugin UR...
65,617
<p>I have two different blogs on the same domain and my goal is to get the 3 latest posts from blog1 to show on the home page of blog2. Everything goes well following these instructions: <a href="http://www.worldoweb.co.uk/2012/display-wordpress-posts-on-another-wp-blog" rel="nofollow">http://www.worldoweb.co.uk/2012/d...
[ { "answer_id": 65629, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>All you're searching for is right inside <a href=\"https://github.com/WordPress/WordPress/blob/3.4.2/wp-admin/inclu...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20598/" ]
I have two different blogs on the same domain and my goal is to get the 3 latest posts from blog1 to show on the home page of blog2. Everything goes well following these instructions: <http://www.worldoweb.co.uk/2012/display-wordpress-posts-on-another-wp-blog> The problem comes when I want to style the image, I need t...
You can remove the a tag with javascript, short and easy. Use the follow plugin; include a small script in the footer of the `edit.php`, only this page in backend of WP and remove all a-tag inside the table; see the selector on the source below. ``` <?php /** * Plugin Name: Remove a * Version: 0.0.1 * Plugin UR...
65,622
<p>I would like to modify the wording in the bulk actions on the posts screen or custom post types. I am trying to do so using the following code, but it's not working. Any idea why?</p> <pre><code>add_filter( 'bulk_actions-edit-post', 'my_custom_bulk_actions' ); function my_custom_bulk_actions( $actions ){ $actio...
[ { "answer_id": 65631, "author": "amit", "author_id": 17968, "author_profile": "https://wordpress.stackexchange.com/users/17968", "pm_score": 1, "selected": false, "text": "<p>As far I know, That hook can only be used to remove particular action.</p>\n\n<blockquote>\n<pre><code>// This fi...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65622", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
I would like to modify the wording in the bulk actions on the posts screen or custom post types. I am trying to do so using the following code, but it's not working. Any idea why? ``` add_filter( 'bulk_actions-edit-post', 'my_custom_bulk_actions' ); function my_custom_bulk_actions( $actions ){ $actions['trash'] = ...
There's currently no possibility to modify those. Just renaming it (the label in the UI only) via JS is possible. I'd recommend to not try to modify those strings, as they equal action names and therefore are part of the query strings. You might break things easily. Figuring out what causes things to brake a half year...
65,632
<p>I have a ridiculous issue with logging users out of my site. Basically, the client has sensitive data and when I call <code>wp_logout_url</code> I redirect to another url. That's fine, but the browser caches the page and can be seen by pressing <em>BACK</em>. </p> <p>Is there ANY way I can stop this happening, or i...
[ { "answer_id": 65729, "author": "soulseekah", "author_id": 9480, "author_profile": "https://wordpress.stackexchange.com/users/9480", "pm_score": 3, "selected": true, "text": "<p>This is not surprising or uncommon, it's how browsers work, the pages are cached and are part of the browser h...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65632", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19231/" ]
I have a ridiculous issue with logging users out of my site. Basically, the client has sensitive data and when I call `wp_logout_url` I redirect to another url. That's fine, but the browser caches the page and can be seen by pressing *BACK*. Is there ANY way I can stop this happening, or is it a non-issue that cannot...
This is not surprising or uncommon, it's how browsers work, the pages are cached and are part of the browser history. This is not specific to WordPress but many web applications out there. There are also different approaches to providing a solution. For one (not very good solution), [clearing the browser history](http...
65,653
<p>Is it possible to remove the "Post Format" meta box from the edit/new post page? The blog in question has a lot of users that keep messing with that but it only uses the standard format post.</p> <p>I'm kind of new to wordpress so excuse me if this is a really obvious one.</p> <p>Thanks.</p>
[ { "answer_id": 65654, "author": "hampusn", "author_id": 20373, "author_profile": "https://wordpress.stackexchange.com/users/20373", "pm_score": 2, "selected": false, "text": "<pre><code>// Higher value on the priority then the default of 10 makes sure this is run after the initial remova...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65653", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20610/" ]
Is it possible to remove the "Post Format" meta box from the edit/new post page? The blog in question has a lot of users that keep messing with that but it only uses the standard format post. I'm kind of new to wordpress so excuse me if this is a really obvious one. Thanks.
That gets added because your theme supports `post-formats`. You can either use a plugin (or a child theme's `functions.php`) file to hook into `after_setup_theme` late and remove theme support: ``` <?php add_action('after_setup_theme', 'wpse65653_remove_formats', 100); function wpse65653_remove_formats() { remove_...
65,658
<p>What is the method to test for the existence of an option in the database?</p> <p>Not the value of the option, just that the option exists.</p>
[ { "answer_id": 65662, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>That's a pretty good question!</p>\n\n<p>Basically you can do several things to get around it, but the most easy is...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65658", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
What is the method to test for the existence of an option in the database? Not the value of the option, just that the option exists.
Options that don't exist get the fact of their non-existence cached in memory when you attempt to get them. So you can check that cache to determine the difference. ``` $value = get_option('example'); $notoptions = wp_cache_get( 'notoptions', 'options' ); if ( isset( $notoptions['example'] ) ) { // option does not...
65,666
<p>How(in wordpress multisite) can i get id of users, who signed up 30 days ago, or more? I am building free trial system for 30 days. I want to have a function, that check when user signed up, and how many days have passed. The function should return number of days that passed.</p> <p>It's easy to get user signed up ...
[ { "answer_id": 65667, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": false, "text": "<p>There's the function <a href=\"http://queryposts.com/function/human_time_diff/\"><code>human_time_diff( $from, $to ...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65666", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20612/" ]
How(in wordpress multisite) can i get id of users, who signed up 30 days ago, or more? I am building free trial system for 30 days. I want to have a function, that check when user signed up, and how many days have passed. The function should return number of days that passed. It's easy to get user signed up time: ```...
There's the function [`human_time_diff( $from, $to );`](http://queryposts.com/function/human_time_diff/), which will compare two UNIX timestamps. Just use [`mktime()`](http://php.net/manual/en/function.mktime.php) on `$GLOBALS['current_user']->user_registered;` and compare it with the current UNIX time.
65,684
<p>I'm trying to improve the localization of the Bones theme. On the admin side it provides an RSS widget which uses the following code:</p> <pre><code>&lt;?php echo $item-&gt;get_date('j F Y @ g:i a'); ?&gt; </code></pre> <p>This uses SimplePie, <a href="http://simplepie.org/wiki/reference/simplepie_item/get_date...
[ { "answer_id": 65685, "author": "Scorchio", "author_id": 12368, "author_profile": "https://wordpress.stackexchange.com/users/12368", "pm_score": 0, "selected": false, "text": "<p>What do you think about this one?</p>\n\n<pre><code>&lt;?php \n echo mysql2date(__('j F Y @ g:i a', 'bones...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65684", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12368/" ]
I'm trying to improve the localization of the Bones theme. On the admin side it provides an RSS widget which uses the following code: ``` <?php echo $item->get_date('j F Y @ g:i a'); ?> ``` This uses SimplePie, [here's the doc](http://simplepie.org/wiki/reference/simplepie_item/get_date) for the method. Which wou...
Best way would probably be to use the built in Internationalization function in WordPress. This will then translate according to the language pack being used. The "U" character to a date() call gives the unix timestamp, which is just what you need in this case, for passing to `date_i18n()`. For example: `echo date_i1...
65,707
<p>I'm creating a site that's basically like an online book, and every post is a chapter. Each chapter gets a customized, specially designed "cover" page that can't really be designed in the Wordpress WYSIWYG. There are certain aspects of each cover that can be templatized (like an h1, h2, and single paragraph — every ...
[ { "answer_id": 65710, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<h2>Custom MarkUp: Post Templates</h2>\n\n<p>Use Page Templates.</p>\n\n<pre><code>function wpse65707_post_templates()...
2012/09/20
[ "https://wordpress.stackexchange.com/questions/65707", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20625/" ]
I'm creating a site that's basically like an online book, and every post is a chapter. Each chapter gets a customized, specially designed "cover" page that can't really be designed in the Wordpress WYSIWYG. There are certain aspects of each cover that can be templatized (like an h1, h2, and single paragraph — every cha...
Another solution, that doesn't invoke page attributes: Explanation: To-Do List ----------------------- Go and download the [`RW_Meta_Box` Library](https://github.com/franz-josef-kaiser/meta-box). *I'm one of the authors/contributers.* The Plugins =========== Here you can see two small plugins (which I wrote especi...
65,720
<p>I am trying to integrate both the values from an existing custom taxonomy and custom author profile fields. I would like the values to be used as the options from which an author can select when updating/filling out her profile.</p> <p>The below works - kind of. (Found in functions.php file)</p> <p>It saves to the...
[ { "answer_id": 65757, "author": "Caroline", "author_id": 20629, "author_profile": "https://wordpress.stackexchange.com/users/20629", "pm_score": 0, "selected": false, "text": "<p>Mamaduka,</p>\n\n<p>Thanks for your response. No, its not a post saving thing - this creating extra user prof...
2012/09/20
[ "https://wordpress.stackexchange.com/questions/65720", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20629/" ]
I am trying to integrate both the values from an existing custom taxonomy and custom author profile fields. I would like the values to be used as the options from which an author can select when updating/filling out her profile. The below works - kind of. (Found in functions.php file) It saves to the database (users ...
Figured it out, for anyone who needs help with this I'm sure you can use with categories/tags as well (can also use with radio inputs and checked="checked": ``` <tr> <th><label for="sorority"><?php _e('Sorority is...') ?></label></th> <td><?php $sorority = get_the_author_meta( 'sorority', $user->ID ); ?> <selec...
65,738
<p>I have to create a membership site, but I need to give every user that registers a automatic ID number.</p> <p>For example, </p> <ul> <li><p>User 2 - has a code - pay-102</p></li> <li><p>User 3 - has a code - pay-103</p></li> </ul> <p>I did a forum search and found this, its pretty much what I am asking - <a href...
[ { "answer_id": 65746, "author": "Lars Koudal", "author_id": 667, "author_profile": "https://wordpress.stackexchange.com/users/667", "pm_score": 2, "selected": true, "text": "<p>Here is some code that reads the highest number from the user meta table and then adds +1 to that number. This ...
2012/09/20
[ "https://wordpress.stackexchange.com/questions/65738", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20637/" ]
I have to create a membership site, but I need to give every user that registers a automatic ID number. For example, * User 2 - has a code - pay-102 * User 3 - has a code - pay-103 I did a forum search and found this, its pretty much what I am asking - [What is the fastest way to generate a unique id number when re...
Here is some code that reads the highest number from the user meta table and then adds +1 to that number. This saves that number for each newly registered user. The code is triggered via the action hook `"user_register"`. ``` add_action( 'user_register', 'assignuserid'); function assignuserid($user_id) { global $w...
65,740
<p>Long story short; I'm writing a plugin in OOP. The constructor is run, but the callback of my add_action does not run. I just can't find out why.</p> <p>I have added echo's on different spots to see what works and what not. The constructor is run, though the <code>pepare()</code> method is not.</p> <p><code>WP_DEB...
[ { "answer_id": 65746, "author": "Lars Koudal", "author_id": 667, "author_profile": "https://wordpress.stackexchange.com/users/667", "pm_score": 2, "selected": true, "text": "<p>Here is some code that reads the highest number from the user meta table and then adds +1 to that number. This ...
2012/09/20
[ "https://wordpress.stackexchange.com/questions/65740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20639/" ]
Long story short; I'm writing a plugin in OOP. The constructor is run, but the callback of my add\_action does not run. I just can't find out why. I have added echo's on different spots to see what works and what not. The constructor is run, though the `pepare()` method is not. `WP_DEBUG` is enabled, though I'm not g...
Here is some code that reads the highest number from the user meta table and then adds +1 to that number. This saves that number for each newly registered user. The code is triggered via the action hook `"user_register"`. ``` add_action( 'user_register', 'assignuserid'); function assignuserid($user_id) { global $w...
65,753
<p>I uploaded around 600 pictures in different galleries in wordpress without setting the titles and alt attributes. I need to edit them, I was wondering a way to edit them by album, let's say the title of the pictures in the album soccer would be soccer1, soccer2 etc.. but without doing it manually?</p>
[ { "answer_id": 140863, "author": "NetWeight Company", "author_id": 50181, "author_profile": "https://wordpress.stackexchange.com/users/50181", "pm_score": -1, "selected": false, "text": "<p>I think the better way to use this plugin - <a href=\"http://wordpress.org/plugins/faster-image-in...
2012/09/19
[ "https://wordpress.stackexchange.com/questions/65753", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I uploaded around 600 pictures in different galleries in wordpress without setting the titles and alt attributes. I need to edit them, I was wondering a way to edit them by album, let's say the title of the pictures in the album soccer would be soccer1, soccer2 etc.. but without doing it manually?
**You can use the 'wp\_get\_attachment\_image\_attributes' hook** ``` add_filter( 'wp_get_attachment_image_attributes', 'image_attributes', 20, 2 ); function image_attributes( $attr, $attachment ) { // Get post parent $parent = get_post_field( 'post_parent', $attachment ); // Get post titl...
65,769
<p>I'm trying to come up with a query to sort by multiple orderby values. Here's what I have so far:</p> <pre><code> $dept_id=2; $query=new WP_Query(array( 'post_type'=&gt;'wpcontactus', 'nopaging'=&gt;true, 'post_status'=&gt;array('publish', 'pending', 'future'), ...
[ { "answer_id": 65772, "author": "Force Flow", "author_id": 7332, "author_profile": "https://wordpress.stackexchange.com/users/7332", "pm_score": 4, "selected": true, "text": "<pre><code>$query=new WP_Query(array(\n 'post_type'=&gt;'wpcontactus',\n 'nopaging'...
2012/09/20
[ "https://wordpress.stackexchange.com/questions/65769", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7332/" ]
I'm trying to come up with a query to sort by multiple orderby values. Here's what I have so far: ``` $dept_id=2; $query=new WP_Query(array( 'post_type'=>'wpcontactus', 'nopaging'=>true, 'post_status'=>array('publish', 'pending', 'future'), 'meta_key'=>'wcu_dept'...
``` $query=new WP_Query(array( 'post_type'=>'wpcontactus', 'nopaging'=>true, 'post_status'=>array('publish', 'pending', 'future'), 'meta_query'=>array( array('key'=>'wcu_dept','value'=>$dept_id, 'compare'=>'='), ...
65,784
<p>I use WordPress <a href="http://wplayout.com/premium-wp-layout-shiny.html" rel="nofollow noreferrer">theme Shiny</a>. I had someone else do my site and now I am trying to figure out how to edit the homepage. The theme version is version <code>1.0.2</code>. </p> <p>How can I edit my homepage?</p>
[ { "answer_id": 65772, "author": "Force Flow", "author_id": 7332, "author_profile": "https://wordpress.stackexchange.com/users/7332", "pm_score": 4, "selected": true, "text": "<pre><code>$query=new WP_Query(array(\n 'post_type'=&gt;'wpcontactus',\n 'nopaging'...
2012/09/20
[ "https://wordpress.stackexchange.com/questions/65784", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20659/" ]
I use WordPress [theme Shiny](http://wplayout.com/premium-wp-layout-shiny.html). I had someone else do my site and now I am trying to figure out how to edit the homepage. The theme version is version `1.0.2`. How can I edit my homepage?
``` $query=new WP_Query(array( 'post_type'=>'wpcontactus', 'nopaging'=>true, 'post_status'=>array('publish', 'pending', 'future'), 'meta_query'=>array( array('key'=>'wcu_dept','value'=>$dept_id, 'compare'=>'='), ...
65,797
<p>Tried to install a wordpress plugin on my local machine:</p> <blockquote> <p>To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.</p> </blockquote> <pre><code>Hostname ...
[ { "answer_id": 65799, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 2, "selected": false, "text": "<p>Are you using Lion? If so, Apple dropped support for managing the FTP service via the Sharing settings. But...
2012/09/20
[ "https://wordpress.stackexchange.com/questions/65797", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11033/" ]
Tried to install a wordpress plugin on my local machine: > > To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host. > > > ``` Hostname 127.0.0.1 FTP Username ...
Depending on your version of OS X, you will need to configure and run FTP and open a port in the firewall. It's best if you google your OS X version - 10.6, 10.7, etc. - specifically and find the docs necessary to set up FTP and Sharing. You also need to realize the security implications of opening up FTP to your loca...
65,855
<p>Is it possible to rewrite only one category ?</p> <p>I have a category "Photos" and just for this category.</p> <p>I just want to rewrite it from /category/photos to /photos</p>
[ { "answer_id": 65861, "author": "Dave Hunt", "author_id": 1769, "author_profile": "https://wordpress.stackexchange.com/users/1769", "pm_score": 0, "selected": false, "text": "<p>You can change the Category Base in Settings -> Permalinks to:</p>\n\n<pre><code>. \n</code></pre>\n\n<p>or </...
2012/09/21
[ "https://wordpress.stackexchange.com/questions/65855", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2000/" ]
Is it possible to rewrite only one category ? I have a category "Photos" and just for this category. I just want to rewrite it from /category/photos to /photos
You can do this with a rewrite rule from within WordPress. Take a look at the documentation for [`add_rewrite_rule`](http://codex.wordpress.org/Rewrite_API/add_rewrite_rule). Something like this: ``` <?php add_action('init', 'wpse65855_rewrite'); function wpse65855_rewrite() { add_rewrite_rule( '^photos/?...
65,857
<p>I want to add a option to the "Gallery settings" (when you insert a gallery into a post).</p> <p>I once found some code on how to do this, but unfortunately I can't find it anymore. I can't even remenber if it was a hook, but I think it was some hackish stuff ;-)</p> <p>Thx</p>
[ { "answer_id": 67448, "author": "Niall Campbell", "author_id": 21219, "author_profile": "https://wordpress.stackexchange.com/users/21219", "pm_score": 2, "selected": false, "text": "<p>hmmm check out the code to Mutliple Galleries plugin, it uses a javascript workaround due to the absenc...
2012/09/21
[ "https://wordpress.stackexchange.com/questions/65857", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18247/" ]
I want to add a option to the "Gallery settings" (when you insert a gallery into a post). I once found some code on how to do this, but unfortunately I can't find it anymore. I can't even remenber if it was a hook, but I think it was some hackish stuff ;-) Thx
Thanks to the hint with the multiple galleries plugin from Niall Campbell and thanks to this question [How to Add a Custom Colum on Thickbox Media Gallery Tab?](https://wordpress.stackexchange.com/questions/53803/how-to-add-a-custom-colum-on-thickbox-media-gallery-tab) (where I got the hook `admin_head-media-upload-pop...
65,890
<p>This sql query</p> <pre><code>$wpdb-&gt;query("UPDATE log SET total=total+1 WHERE id='1')"); </code></pre> <p>How do I turn it into $wpdb->update() statement?</p> <p>Ex.</p> <pre><code>$wpdb-&gt;update('log', array('total'=&gt;'total+1'), array('id'=&gt;'1')); </code></pre>
[ { "answer_id": 65898, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 4, "selected": true, "text": "<p>You don't. Not with the WPDB update() function. The update function assumes that the values of the columns are strin...
2012/09/21
[ "https://wordpress.stackexchange.com/questions/65890", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12397/" ]
This sql query ``` $wpdb->query("UPDATE log SET total=total+1 WHERE id='1')"); ``` How do I turn it into $wpdb->update() statement? Ex. ``` $wpdb->update('log', array('total'=>'total+1'), array('id'=>'1')); ```
You don't. Not with the WPDB update() function. The update function assumes that the values of the columns are strings. You can override that with the format parameter, but that only allows %d, %f, and %s (integer, float, string). It doesn't allow operations on columns like total+1. You'd have to use the query() funct...
65,911
<p>Let's say I have a category named as <code>catname</code> (the slug would be <code>catname</code>). I want the header styled differently when visitors open the category catname.</p> <p>The <a href="http://www.ghacks.net/2011/03/24/wordpress-customer-headers-for-categories/" rel="nofollow">article on Ghacks</a> expl...
[ { "answer_id": 65921, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>Both approaches a almost equal. Access to the file system is always slower than plain PHP execution in a file. </p>\n\...
2012/09/21
[ "https://wordpress.stackexchange.com/questions/65911", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13291/" ]
Let's say I have a category named as `catname` (the slug would be `catname`). I want the header styled differently when visitors open the category catname. The [article on Ghacks](http://www.ghacks.net/2011/03/24/wordpress-customer-headers-for-categories/) explains how to create a custom header (styled differently) wh...
The article on Ghacks is actually a pretty silly way to do it as well. The `get_header()` function is actually a pretty smart function. You can do some neat things with it. For example, you can do this: `get_header('category');` That will cause it to load the header-category.php file, if such a file exists, or the h...
65,916
<p>Actually a simple question, but I need to be sure that assigning a variable for the result of a function can help to increase the speed of a site e.g.</p> <p>The function: <code>if is_paged(){ $paged = 1; }</code></p> <p>The replacement: <code> if $paged == "1" .. then do </code> - RATHER THAN USING THE SAME FUNCT...
[ { "answer_id": 65917, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>No.</p>\n\n<p>Query conditionals are part of WordPress' object cache, and incur no additional resources whe...
2012/09/21
[ "https://wordpress.stackexchange.com/questions/65916", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7820/" ]
Actually a simple question, but I need to be sure that assigning a variable for the result of a function can help to increase the speed of a site e.g. The function: `if is_paged(){ $paged = 1; }` The replacement: `if $paged == "1" .. then do` - RATHER THAN USING THE SAME FUNCTION over and over W3 total cache would...
So, all [query conditionals](http://codex.wordpress.org/Conditional_Tags) (`is_paged`, `is_singular`, etc) look something like this: ``` function is_paged() { global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run....
65,927
<p>I have done this before but for some reason, it is not working and I can't figure out why. All I am trying to do is exclude some categories from the blog page. I thought this would be a simple matter. I have the index.php file open, and before my loop, I did this</p> <pre><code> query_posts( $guery_string . '&amp;c...
[ { "answer_id": 65931, "author": "Rachel Baker", "author_id": 8054, "author_profile": "https://wordpress.stackexchange.com/users/8054", "pm_score": 0, "selected": false, "text": "<p>What happens if you use just: </p>\n\n<p><code>query_posts( 'cat=-6' );</code></p>\n\n<p>?</p>\n\n<p>You sh...
2012/09/22
[ "https://wordpress.stackexchange.com/questions/65927", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14761/" ]
I have done this before but for some reason, it is not working and I can't figure out why. All I am trying to do is exclude some categories from the blog page. I thought this would be a simple matter. I have the index.php file open, and before my loop, I did this ``` query_posts( $guery_string . '&cat=-6' ) if (have...
[**Don't use `query_posts()`**](http://www.slideshare.net/andrewnacin/you-dont-know-query-wordcamp-netherlands-2012). Filter [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) instead: ``` function wpse65927_filter_pre_get_posts( $query ) { // If this is the blog posts index, ...
65,934
<p>I built a custom search page with a form like:</p> <pre><code>&lt;form role="search" method="get" id="searchform" action="&lt;?php echo home_url( '/' ); ?&gt;"&gt; </code></pre> <p>trouble is I want the results to appear in search.php</p> <p>whereas I m led to index.php</p> <p>How can I force to always go to sea...
[ { "answer_id": 65943, "author": "2hamed", "author_id": 7410, "author_profile": "https://wordpress.stackexchange.com/users/7410", "pm_score": 1, "selected": true, "text": "<p>If I get it correctly Wordpress loads the search template dynamically by the parameters delivered to it. Specifica...
2012/09/22
[ "https://wordpress.stackexchange.com/questions/65934", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16266/" ]
I built a custom search page with a form like: ``` <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>"> ``` trouble is I want the results to appear in search.php whereas I m led to index.php How can I force to always go to search.php ?
If I get it correctly Wordpress loads the search template dynamically by the parameters delivered to it. Specifically the `s` parameter. Meaning if you try to send the user to the `http://www.example.com/search.php` you'll get 404 error page. For now the only workaround I can think is to create a function which is h...
65,947
<p>I have been trying a way round my latest WordPress problem all morning and I feel now is the right time to shout and ask for help.</p> <p>I have been trying to create a people directory, I'm there except for the overall listing page which I have decided to be rows of 5 images followed by the persons name below each...
[ { "answer_id": 65950, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_attachment_image\" rel=\"nofollow\"><code>wp_get_att...
2012/09/22
[ "https://wordpress.stackexchange.com/questions/65947", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17462/" ]
I have been trying a way round my latest WordPress problem all morning and I feel now is the right time to shout and ask for help. I have been trying to create a people directory, I'm there except for the overall listing page which I have decided to be rows of 5 images followed by the persons name below each image, fo...
Use [`wp_get_attachment_image( $id )`](http://codex.wordpress.org/Function_Reference/wp_get_attachment_image). Sample code: ``` print wp_get_attachment_image( $main_image, array ( 80, 80 ), FALSE, array ( 'alt' => 'portrait' ) ); ```
65,948
<p>I'm in the process of migrating my blog from Drupal to Wordpress. I have made liberal use of Markdown in the original posts (and Geshi syntax highlighting). </p> <p>In see that the WP-Markdown plugin converts to (and from HTML) on save (and edit), so I now have a bunch of posts which appear with the Markdown 'on ...
[ { "answer_id": 66543, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 4, "selected": true, "text": "<p><strong><em>Note:</strong> The following is largely untested (It worked after testing on one post).</em></...
2012/09/22
[ "https://wordpress.stackexchange.com/questions/65948", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20717/" ]
I'm in the process of migrating my blog from Drupal to Wordpress. I have made liberal use of Markdown in the original posts (and Geshi syntax highlighting). In see that the WP-Markdown plugin converts to (and from HTML) on save (and edit), so I now have a bunch of posts which appear with the Markdown 'on show'. Is t...
***Note:*** The following is largely untested (It worked after testing on one post). As you've pointed out when you edit a post, the plug-in takes the content in the database (HTML) and converts that to MarkDown for editing. Since in your case the content is actually not in HTML, but already in MarkDown, we want to st...
65,955
<p>I have a situation where I want to give specific style to my Navigation Menu when the website is in German language.</p> <p>My website works well in English language but when I switch to German, it causes a css problem.</p> <p>So how do I determine which language is currently active with qTranslate plugin?</p>
[ { "answer_id": 65956, "author": "Darshan Thanki", "author_id": 18711, "author_profile": "https://wordpress.stackexchange.com/users/18711", "pm_score": 3, "selected": false, "text": "<p>I have found a possible solution:</p>\n\n<pre><code>if ( 'de' === $GLOBALS['q_config']['language'])\n{\...
2012/09/22
[ "https://wordpress.stackexchange.com/questions/65955", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18711/" ]
I have a situation where I want to give specific style to my Navigation Menu when the website is in German language. My website works well in English language but when I switch to German, it causes a css problem. So how do I determine which language is currently active with qTranslate plugin?
I have found a possible solution: ``` if ( 'de' === $GLOBALS['q_config']['language']) { echo "<style>#nav li a { margin-left:3px !important; }</style>"; // menu bar width fix } ``` This works well for my menu items being not looking wired.
65,959
<p>I'm working a private blog and I'd like to know if this can be done with any other plugin or any other way: Lets say we have 3 categories: CA, CB and CC, and 3 users, UA, UB and UC, all of them can post but only in a particular category, UA in CA and so on. Now when one of them login to see the blog, this will only ...
[ { "answer_id": 65960, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>That's actually pretty easy with WP on board functions and the <a href=\"http://codex.wordpress.org/Template_Hierar...
2012/09/22
[ "https://wordpress.stackexchange.com/questions/65959", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19156/" ]
I'm working a private blog and I'd like to know if this can be done with any other plugin or any other way: Lets say we have 3 categories: CA, CB and CC, and 3 users, UA, UB and UC, all of them can post but only in a particular category, UA in CA and so on. Now when one of them login to see the blog, this will only sho...
This is awesome material for a plugin. This answer will also include how to associate the user with the category (it's hard to give you a solution without knowing that). Before we get started, the real meat is in step four (way at the bottom). Skip to that if you don't need a way to associate categories with users. S...
65,962
<p>I am trying to make a notification function for a user's account dashboard that displays if they have not added any images to their profile's gallery. I found this page, which is a function that checks if the CURRENT page has any attachments: <a href="https://wordpress.stackexchange.com/questions/20218/check-if-post...
[ { "answer_id": 65966, "author": "2hamed", "author_id": 7410, "author_profile": "https://wordpress.stackexchange.com/users/7410", "pm_score": 0, "selected": false, "text": "<p>According to that question you mentioned, you need to the have the post content in order to check if there is a g...
2012/09/22
[ "https://wordpress.stackexchange.com/questions/65962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18066/" ]
I am trying to make a notification function for a user's account dashboard that displays if they have not added any images to their profile's gallery. I found this page, which is a function that checks if the CURRENT page has any attachments: [Check if post/page has gallery?](https://wordpress.stackexchange.com/questio...
``` $args = array( 'post_type' => 'attachment', 'numberposts' => null, 'post_status' => null, 'post_parent' => $post_id ); $attachments = get_posts($args); if ($attachments) { echo "attachments rock!"; } } ``` If you want to make sure the atachements are an image, you would use: ``` if ( $att...
65,981
<p>I am trying to pass a variable to the callback function through <code>add_meta_box</code>. I know that there is <code>$callback_args</code> that can be used to pass the variable. But somehow I just can't get it to work within a class. This is my code:</p> <pre class="lang-php prettyprint-override"><code>class myclas...
[ { "answer_id": 65985, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 4, "selected": true, "text": "<p>Sometimes an example says more than a thousand words. Here's a small plugin that will guide you:</p>\n\n<pre><code>&...
2012/09/22
[ "https://wordpress.stackexchange.com/questions/65981", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14728/" ]
I am trying to pass a variable to the callback function through `add_meta_box`. I know that there is `$callback_args` that can be used to pass the variable. But somehow I just can't get it to work within a class. This is my code: ```php class myclass{ //...blah blah...adding action function add_ex_field() { ad...
Sometimes an example says more than a thousand words. Here's a small plugin that will guide you: ``` <?php ! defined( 'ABSPATH' ) AND exit; /** * Plugin Name: (#65981) »kaiser« Meta Box example * Plugin URI: http://goo.gl/ls6Q6 * Description: Example showing how to add a meta box with callback args * Author: ...
65,989
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://wordpress.stackexchange.com/questions/39446/change-the-title-of-a-meta-box">Change The Title Of a Meta Box</a> </p> </blockquote> <p>Is it possible to change the title of a Meta Box on a specific Custom Post Type add or edit page?</p> <p...
[ { "answer_id": 65992, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 1, "selected": false, "text": "<p>Yes - you need a slightly modified version of <a href=\"https://wordpress.stackexchange.com/questions/394...
2012/09/22
[ "https://wordpress.stackexchange.com/questions/65989", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9579/" ]
> > **Possible Duplicate:** > > [Change The Title Of a Meta Box](https://wordpress.stackexchange.com/questions/39446/change-the-title-of-a-meta-box) > > > Is it possible to change the title of a Meta Box on a specific Custom Post Type add or edit page? For example, if I'm viewing the post type add or edit pag...
Yes - you need a slightly modified version of [this answer](https://wordpress.stackexchange.com/questions/39446/change-the-title-of-a-meta-box/39447#39447). ``` add_action( 'add_meta_boxes_post', 'wpse39446_add_meta_boxes' ); function wpse39446_add_meta_boxes( $post ) { if( 'mycpt' == get_post_type($post) ){ ...
66,004
<p>The aim is for a proposed site to have customers be able to login and be able to view a private and customer specific ADMIN page NOT frontend page (although this would be much easier to achieve).</p> <p>Said page would display user meta and content that the site Admin could add ad hoc.</p> <p>I am confident in bei...
[ { "answer_id": 66009, "author": "2hamed", "author_id": 7410, "author_profile": "https://wordpress.stackexchange.com/users/7410", "pm_score": -1, "selected": false, "text": "<p>In my opinion your best bet is to meddle with <a href=\"http://www.garyc40.com/2010/04/ultimate-guide-to-roles-a...
2012/09/23
[ "https://wordpress.stackexchange.com/questions/66004", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14542/" ]
The aim is for a proposed site to have customers be able to login and be able to view a private and customer specific ADMIN page NOT frontend page (although this would be much easier to achieve). Said page would display user meta and content that the site Admin could add ad hoc. I am confident in being able to create...
You can add a new page using [`add_(sub)menu_page();`](http://codex.wordpress.org/Function_Reference/add_menu_page). WordPress is pretty kind in this case and offers tons of hooks, filters and higher level API functions that help you going around this. Let's just use [`add_users_page();`](http://codex.wordpress.org/Fu...
66,005
<p>Hi we all know by default tiny MCE's blockquote generates this</p> <pre><code>&lt;blockquote&gt; content here &lt;/blockquote&gt; </code></pre> <p>I am styling this via CSS :</p> <p><img src="https://i.stack.imgur.com/e3zza.jpg" alt="enter image description here"></p> <p>the css im using :</p> <pre><code>blockq...
[ { "answer_id": 66006, "author": "deathlock", "author_id": 13291, "author_profile": "https://wordpress.stackexchange.com/users/13291", "pm_score": -1, "selected": true, "text": "<p>If it's for styling purpose, the fastest solution I could think of is by using Javascript. As far as I know,...
2012/09/23
[ "https://wordpress.stackexchange.com/questions/66005", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20728/" ]
Hi we all know by default tiny MCE's blockquote generates this ``` <blockquote> content here </blockquote> ``` I am styling this via CSS : ![enter image description here](https://i.stack.imgur.com/e3zza.jpg) the css im using : ``` blockquote { border: none; font-family: 'Georgia', serif; color: #444; font-size: 1...
If it's for styling purpose, the fastest solution I could think of is by using Javascript. As far as I know, modifying the output of TinyMCE tag would require editing of Wordpress core files, so it's more practical to append a `<span>` with Javascript. Something like this would do: ``` <script type="text/javascript> ...
66,034
<p>I am using the template_redirect action to redirect a user to a custom template which has no header, sidebar or footer (the intent is for it to be in an iframe as a dialog box). After I done the redirect though, I could not seem to get all the enqueued JS and CSS to list.</p> <p>Here's the code:</p> <pre><code> ...
[ { "answer_id": 66006, "author": "deathlock", "author_id": 13291, "author_profile": "https://wordpress.stackexchange.com/users/13291", "pm_score": -1, "selected": true, "text": "<p>If it's for styling purpose, the fastest solution I could think of is by using Javascript. As far as I know,...
2012/09/23
[ "https://wordpress.stackexchange.com/questions/66034", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/945/" ]
I am using the template\_redirect action to redirect a user to a custom template which has no header, sidebar or footer (the intent is for it to be in an iframe as a dialog box). After I done the redirect though, I could not seem to get all the enqueued JS and CSS to list. Here's the code: ``` <?php /** ...
If it's for styling purpose, the fastest solution I could think of is by using Javascript. As far as I know, modifying the output of TinyMCE tag would require editing of Wordpress core files, so it's more practical to append a `<span>` with Javascript. Something like this would do: ``` <script type="text/javascript> ...
66,036
<p>This is the code of continue reading in function.php</p> <pre><code>&lt;?php the_content( __( 'Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyten' ) ); ?&gt; </code></pre> <p>It has a class which named <strong>meta-nav</strong> I tried to find the class and change it but I couldn't ...
[ { "answer_id": 66043, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 1, "selected": false, "text": "<p>the css class <code>.meta-nav</code> might or might not be referenced in style.css or any other stylesheet of th...
2012/09/23
[ "https://wordpress.stackexchange.com/questions/66036", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20321/" ]
This is the code of continue reading in function.php ``` <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?> ``` It has a class which named **meta-nav** I tried to find the class and change it but I couldn't find that. Where is that? Thanks in advance
the css class `.meta-nav` might or might not be referenced in style.css or any other stylesheet of the theme. if your theme is ***Twenty Ten*** then the css class is ***not*** used in style.css - add it as a new style if you need.
66,041
<p>Getting started on Wordpress just today. I noticed that Wordpress created tables in a mySql database (with name *.wrdp1) when I first set it up. These tables cover comments, posts, users, and some link-relationships.</p> <p>Now, let's say I would like to work with a new set of data. Suppose I were to create a page ...
[ { "answer_id": 66063, "author": "Tomas Buteler", "author_id": 5552, "author_profile": "https://wordpress.stackexchange.com/users/5552", "pm_score": 2, "selected": true, "text": "<p>WordPress has a pretty flexible way of handling custom data, and it stores it in a table called wp_postmeta...
2012/09/23
[ "https://wordpress.stackexchange.com/questions/66041", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20740/" ]
Getting started on Wordpress just today. I noticed that Wordpress created tables in a mySql database (with name \*.wrdp1) when I first set it up. These tables cover comments, posts, users, and some link-relationships. Now, let's say I would like to work with a new set of data. Suppose I were to create a page with two ...
WordPress has a pretty flexible way of handling custom data, and it stores it in a table called wp\_postmeta (assuming default wp\_ prefix). The only catch is that it assumes that it will somehow be related to a certain post, which I'm not sure you actually want to do. It's very simple to use (see [here](http://codex....
66,057
<p>How can I add a custom image upload size with a width of 550px and make it selected by default in the Add Media page?</p> <p>Currently, there are 4 sizes available: <code>Thumbnail</code>, <code>Medium</code>, <code>Large</code> and <code>Full Size</code>. The <code>Full Size</code> option is selected by default.</...
[ { "answer_id": 66058, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>Just set all other options to <code>0</code> in your Admin panel under \"Settings\" » \"Media\". This will disable ...
2012/09/23
[ "https://wordpress.stackexchange.com/questions/66057", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18482/" ]
How can I add a custom image upload size with a width of 550px and make it selected by default in the Add Media page? Currently, there are 4 sizes available: `Thumbnail`, `Medium`, `Large` and `Full Size`. The `Full Size` option is selected by default. Anyone knows a working solution to this?
There are a few steps to this, as I found out today. First, you add a custom image size (you can put this somewhere the `functions.php` file in your theme): ```php add_theme_support( 'post-thumbnails' ); add_image_size( 'my-size', 550, 550 ); // not sure what you want your height to ...
66,059
<p>I modified this code from the Twenty Eleven theme but it doesn't work and I cant see why.</p> <pre><code>if ( ! function_exists( 'theme_post_meta_data' ) ) : /** * This function prints post meta data. * * Adopted from Twenty Eleven */ function theme_post_meta_data() { printf( __( '%1$sPosted on %2$s by %3$s...
[ { "answer_id": 66075, "author": "Jamie", "author_id": 14761, "author_profile": "https://wordpress.stackexchange.com/users/14761", "pm_score": 0, "selected": false, "text": "<p>you spelled your function wrong. You have thme_post_meta_data() instead of theme_post_meta_data. Therefore, you ...
2012/09/23
[ "https://wordpress.stackexchange.com/questions/66059", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17937/" ]
I modified this code from the Twenty Eleven theme but it doesn't work and I cant see why. ``` if ( ! function_exists( 'theme_post_meta_data' ) ) : /** * This function prints post meta data. * * Adopted from Twenty Eleven */ function theme_post_meta_data() { printf( __( '%1$sPosted on %2$s by %3$s', 'theme' ), ...
I solved the problem by using this code. ``` if ( ! function_exists( 'theme_post_meta_data' ) ) : /** * This function prints post meta data. */ function theme_post_meta_data() { printf( __( '<span class="%1$s">Posted on </span>%2$s<span class="%3$s"> by </span>%4$s', 'theme' ), 'meta-prep meta-prep-author posted', sp...
66,065
<p>I am using WordPress as the CMS for my website. For my navigation menu, I am using WordPress' inbuilt navigation menu function. You add categories, page, etc, to this and it generates a list with certain classes you can style - like <code>current-menu-item</code>.</p> <p>My problem lies here: </p> <ul> <li><p>I ha...
[ { "answer_id": 66078, "author": "Just Thomas Misund", "author_id": 20580, "author_profile": "https://wordpress.stackexchange.com/users/20580", "pm_score": 2, "selected": false, "text": "<p>This question was also asked <a href=\"https://stackoverflow.com/questions/12557832/multiple-menu-i...
2012/09/24
[ "https://wordpress.stackexchange.com/questions/66065", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20756/" ]
I am using WordPress as the CMS for my website. For my navigation menu, I am using WordPress' inbuilt navigation menu function. You add categories, page, etc, to this and it generates a list with certain classes you can style - like `current-menu-item`. My problem lies here: * I have several categories in my menu, a...
This question was also asked [on stackoverflow](https://stackoverflow.com/questions/12557832/multiple-menu-items-highlighted-in-wordpress). Here's a copy of the answer i gave there: Perhaps you could style it using the `nth-of-type` CSS3 selector. ``` .current-menu-item:nth-of-type(1) { background:#ffff00; /*...
66,066
<p>I'm extremely new to Wordpress, and I've offered to help out with a project that uses it.</p> <p>In a new page I'm creating, I need to use javascript/jQuery to write out the html dynamically - it doesn't seem to be working? I believe I read there was something special that needed to be done, but I can't figure out....
[ { "answer_id": 66069, "author": "Just Thomas Misund", "author_id": 20580, "author_profile": "https://wordpress.stackexchange.com/users/20580", "pm_score": 2, "selected": false, "text": "<p>You need to make sure that jQuery is loaded, so that you can use it.</p>\n\n<p>In functions.php:</p...
2012/09/24
[ "https://wordpress.stackexchange.com/questions/66066", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20758/" ]
I'm extremely new to Wordpress, and I've offered to help out with a project that uses it. In a new page I'm creating, I need to use javascript/jQuery to write out the html dynamically - it doesn't seem to be working? I believe I read there was something special that needed to be done, but I can't figure out. I tried c...
You need to make sure that jQuery is loaded, so that you can use it. In functions.php: ``` function namespace_enqueue_scripts() { if ( is_page( 'slug-of-new-page-you-are-creating' ) ) wp_enqueue_script('jquery'); } add_action( 'wp_enqueue_scripts', 'namespace_enqueue_scripts' ); ```
66,084
<p>Is it possible to unserialize data in the mysql query at the run time? i don't want to use unserialize() function of php. </p> <p>I need to fetch the value "mathematics" from the below serialized value saved in wp_postmeta table using mysql query.</p> <pre><code>a:4:{s:39:"wpcf-fields-checkboxes-option-223412915";...
[ { "answer_id": 66085, "author": "swtshweta", "author_id": 14123, "author_profile": "https://wordpress.stackexchange.com/users/14123", "pm_score": 0, "selected": false, "text": "<p>You can use get_post_meta() function for fetching this value. For ex. </p>\n\n<pre><code>&lt;?php\n$options ...
2012/09/24
[ "https://wordpress.stackexchange.com/questions/66084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19310/" ]
Is it possible to unserialize data in the mysql query at the run time? i don't want to use unserialize() function of php. I need to fetch the value "mathematics" from the below serialized value saved in wp\_postmeta table using mysql query. ``` a:4:{s:39:"wpcf-fields-checkboxes-option-223412915";s:7:"science";s:39:"...
Ideally, post meta should never be stored in a serialized form to begin with, thus making it easy to query. If the code uses the standard methods for storing meta instead of self-serializing it, then each item would be in its own row and easily queryable. If the data is stored serialized, then you have very few option...
66,093
<p>I did try using the plugin Front End Users but this clashes with something as it prevents access to some front end pages. So I need to manually just set it so that anyone who isn't one of two usernames (or roles) can't access wp-admin.</p>
[ { "answer_id": 66104, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 5, "selected": true, "text": "<h2>Plugin</h2>\n\n<p>It's basically just a user capability check, followed by a redirect in an exit call. It then redi...
2012/09/24
[ "https://wordpress.stackexchange.com/questions/66093", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14739/" ]
I did try using the plugin Front End Users but this clashes with something as it prevents access to some front end pages. So I need to manually just set it so that anyone who isn't one of two usernames (or roles) can't access wp-admin.
Plugin ------ It's basically just a user capability check, followed by a redirect in an exit call. It then redirects to the site the request came from. ``` <?php ! defined( 'ABSPATH' ) AND exit; /* Plugin Name: (#66093) »kaiser« Deny Admin-UI access for certain roles */ function wpse66093_no_admin_access() { // ...
66,102
<p>I've created a custom post type with my requirements. I used "WP Video Gen" as menu label. But I want red marked item to name as "Videos". Is it possible? Ref: <a href="http://ScrnSht.com/jcvlhy" rel="noreferrer">http://ScrnSht.com/jcvlhy</a></p> <p>Thanks in advanced.</p>
[ { "answer_id": 66103, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p><img src=\"https://i.stack.imgur.com/2wOKa.jpg\" alt=\"enter image description here\"></p>\n\n<blockquote>\n <p>Is...
2012/09/24
[ "https://wordpress.stackexchange.com/questions/66102", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8096/" ]
I've created a custom post type with my requirements. I used "WP Video Gen" as menu label. But I want red marked item to name as "Videos". Is it possible? Ref: <http://ScrnSht.com/jcvlhy> Thanks in advanced.
When you register your custom post type there's an argument called 'labels' you can pass to `register_post_type()`. The argument is an associative array with named labels for the menu and screens of your post type. Specifically, the label you are looking for is called 'all\_items'. I don't know your code for registeri...
66,105
<p>In one of my page I have to fetch data from remote mysql database. We have connection to remote mysql database by creating new instance of $wpdb class.</p> <p>$mydb = new wpdb(DB_USER2, DB_PASSWORD2, DB_NAME2, DB_HOST2);</p> <p>$post_author=$mydb->get_row("Select display_name from wp_users where ID=1");</p> <p>Th...
[ { "answer_id": 66109, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>The WordPress APIs rely on the global $wpdb object, you can define any arbitrary object of type wpdb but that...
2012/09/24
[ "https://wordpress.stackexchange.com/questions/66105", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20714/" ]
In one of my page I have to fetch data from remote mysql database. We have connection to remote mysql database by creating new instance of $wpdb class. $mydb = new wpdb(DB\_USER2, DB\_PASSWORD2, DB\_NAME2, DB\_HOST2); $post\_author=$mydb->get\_row("Select display\_name from wp\_users where ID=1"); The above query is...
The WordPress APIs rely on the global $wpdb object, you can define any arbitrary object of type wpdb but that doesn't mean WordPress will use it. Instead, something akin to the following might be better: ``` global $wpdb; $tempDB = $wpdb; $wpdb = new wpdb(DB_USER2, DB_PASSWORD2, DB_NAME2, DB_HOST2); // do your remote...
66,106
<p>I'm trying to make a custom template for my category pages that only pulls in post under a specific category. At the moment, I am only able to pull in all post and not category specific...</p> <p>My code so far....</p> <pre><code>&lt;?php //Identify current Post-Category-ID foreach((get_the_category()) as ...
[ { "answer_id": 66117, "author": "soumendu", "author_id": 20714, "author_profile": "https://wordpress.stackexchange.com/users/20714", "pm_score": -1, "selected": false, "text": "<p>using the following code you can fetch all the post of this category.If you want to limit the number of post...
2012/09/24
[ "https://wordpress.stackexchange.com/questions/66106", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20768/" ]
I'm trying to make a custom template for my category pages that only pulls in post under a specific category. At the moment, I am only able to pull in all post and not category specific... My code so far.... ``` <?php //Identify current Post-Category-ID foreach((get_the_category()) as $category) { ...
You've already got code to figure out which category you want to show posts from, here is how you would grab all the posts in that category: ``` // create a query to grab our posts in category of ID $postcat $q = new WP_Query(array( 'cat' => $postcat)); if($q->have_posts()){ // foreach post found while($q->hav...
66,115
<p>I have multi-site wordpress, I want to redirect the main site to one of the sub-site but redirection in .htacecss gives error. Is there any way to redirect a main site to its sub-site. That looks not possible but I am not a wordpress expert so just verifying.</p> <p>The redirect should be like </p> <p>redirect 301...
[ { "answer_id": 66404, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 4, "selected": true, "text": "<p>You can use the <code>parse_request</code> action to accomplish this. Simply enable this plugin on your prim...
2012/09/24
[ "https://wordpress.stackexchange.com/questions/66115", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20773/" ]
I have multi-site wordpress, I want to redirect the main site to one of the sub-site but redirection in .htacecss gives error. Is there any way to redirect a main site to its sub-site. That looks not possible but I am not a wordpress expert so just verifying. The redirect should be like redirect 301 www.example.com/...
You can use the `parse_request` action to accomplish this. Simply enable this plugin on your primary blog. Place the following code in a .php file and upload it to your plugins directory. ``` /* Plugin Name: Redirect Main Site To Sub-Site Description: Redirect 'main-site' to 'main-site/sub-site/' Version: 0.1 Author: ...
66,130
<p>Customized wp_new_user_notification</p> <p>I'm kind of inexperienced with it comes to editing Wordpress functions, yet i'm currently trying to customize <a href="http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/pluggable.php#L1188" rel="nofollow noreferrer"><code>wp_new_user_notification</code></a> in ...
[ { "answer_id": 66404, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 4, "selected": true, "text": "<p>You can use the <code>parse_request</code> action to accomplish this. Simply enable this plugin on your prim...
2012/09/24
[ "https://wordpress.stackexchange.com/questions/66130", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16281/" ]
Customized wp\_new\_user\_notification I'm kind of inexperienced with it comes to editing Wordpress functions, yet i'm currently trying to customize [`wp_new_user_notification`](http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/pluggable.php#L1188) in order to personalize the email that administrators and ...
You can use the `parse_request` action to accomplish this. Simply enable this plugin on your primary blog. Place the following code in a .php file and upload it to your plugins directory. ``` /* Plugin Name: Redirect Main Site To Sub-Site Description: Redirect 'main-site' to 'main-site/sub-site/' Version: 0.1 Author: ...
66,166
<p>I know how to disable HTML in comments, but I'd like the ability to only have Admins be able to post links, or only Logged In users if need be, to have the ability to post links. Is this possible?</p> <p>I am currently <a href="http://www.stefannilsson.com/remove-links-in-comments/" rel="nofollow">using this plugi...
[ { "answer_id": 66172, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>I'm not sure, but from a brief look it seems like that there's only the <code>global $allowedtags;</code> for this ...
2012/09/24
[ "https://wordpress.stackexchange.com/questions/66166", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20796/" ]
I know how to disable HTML in comments, but I'd like the ability to only have Admins be able to post links, or only Logged In users if need be, to have the ability to post links. Is this possible? I am currently [using this plugin](http://www.stefannilsson.com/remove-links-in-comments/). I wrote the author of the plu...
Additional info by the OP ------------------------- It seems that the OP "forgot" to tell, that he uses the following plugin: ``` <?php /* Plugin Name: Remove Links in Comments Plugin URI: http://www.stefannilsson.com/remove-links-in-comments/ Description: Deactivate hyperlinks in comments. */ function remove_links(...
66,197
<p>I´d like to link <code>the_post_thumbnail</code> by using the <code>the_permalink</code>.</p> <p>I do this (<strong>It Works without link</strong>)</p> <pre><code>&lt;?php $args = array( 'post_type' =&gt; 'xyz', 'posts_per_page' =&gt; -1, 'orderby' =&gt; 'rand' ); $loop = new WP_Query( $args ); while ( $loop-&g...
[ { "answer_id": 66199, "author": "Just Thomas Misund", "author_id": 20580, "author_profile": "https://wordpress.stackexchange.com/users/20580", "pm_score": 0, "selected": false, "text": "<p>You need to jump out of PHP after calling <code>$loop-&gt;the_post()</code>, because you are writin...
2012/09/25
[ "https://wordpress.stackexchange.com/questions/66197", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12521/" ]
I´d like to link `the_post_thumbnail` by using the `the_permalink`. I do this (**It Works without link**) ``` <?php $args = array( 'post_type' => 'xyz', 'posts_per_page' => -1, 'orderby' => 'rand' ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); the_post_thumbnail('wine-flow',...
That is because you haven't close php before anchor tag ``` <?php $args = array( 'post_type' => 'xyz', 'posts_per_page' => -1, 'orderby' => 'rand' ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > ...
66,205
<p>I have a problem with two websites. For example:</p> <p><code>http://first.site</code></p> <p><code>http://second.site</code></p> <p>How can I make a clone of <code>first.site</code> to <code>seconds.site</code>? I want a method that I can do in a few minutes: does not involve changing the database, deleting it, ...
[ { "answer_id": 66548, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 1, "selected": false, "text": "<h1>Caveat</h1>\n\n<p>This is extremely bad for SEO. Having duplicate content can ultimately cause your site(s...
2012/09/25
[ "https://wordpress.stackexchange.com/questions/66205", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20805/" ]
I have a problem with two websites. For example: `http://first.site` `http://second.site` How can I make a clone of `first.site` to `seconds.site`? I want a method that I can do in a few minutes: does not involve changing the database, deleting it, create it, copying it, etc. The clone must be exactly the same, exc...
Caveat ====== This is extremely bad for SEO. Having duplicate content can ultimately cause your site(s) to [be removed from search results](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=66359). Solution ======== This is actually pretty simple to have one database and disk content. Point both of the...
66,207
<p>I have a wordpress website with bunch of posts. My problem is that I need to change the URLs from</p> <pre><code>website.com/post-name </code></pre> <p>to </p> <pre><code>website.com/specialword/post-name </code></pre> <p>The "specialword" is what I need to add in front of those post names, but ONLY for the pos...
[ { "answer_id": 66210, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 2, "selected": false, "text": "<p>You can do it from <code>Settings &gt; Permalinks</code>.</p>\n\n<p>Select the <code>Custom Structure</...
2012/09/25
[ "https://wordpress.stackexchange.com/questions/66207", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7069/" ]
I have a wordpress website with bunch of posts. My problem is that I need to change the URLs from ``` website.com/post-name ``` to ``` website.com/specialword/post-name ``` The "specialword" is what I need to add in front of those post names, but ONLY for the post type - posts. Can someone help me? I need thi...
You can do it from `Settings > Permalinks`. Select the `Custom Structure` radio button, and put this in the text field next to it: ``` /myspecialword/%postname% ``` Works.
66,219
<p>Is there a way I can list all posts in a specific custom post type and arrange them by the custom taxonomy term attached to them?</p> <p>For example;</p> <p><strong>Taxonmy Term #1</strong><br/> Post Type<br/> Post Type<br/> Post Type<br/></p> <p><strong>Taxonomy Term #2</strong><br/> Post Type<br/> Post Type<br/...
[ { "answer_id": 66229, "author": "theMojoWill", "author_id": 20503, "author_profile": "https://wordpress.stackexchange.com/users/20503", "pm_score": 2, "selected": false, "text": "<p>Not a particularly elegant solution but you can create multiple queries each for the specific terms and th...
2012/09/25
[ "https://wordpress.stackexchange.com/questions/66219", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18547/" ]
Is there a way I can list all posts in a specific custom post type and arrange them by the custom taxonomy term attached to them? For example; **Taxonmy Term #1** Post Type Post Type Post Type **Taxonomy Term #2** Post Type Post Type Any help would be most appreciated. Thanks.
Try this ``` $custom_terms = get_terms('custom_taxonomy'); foreach($custom_terms as $custom_term) { wp_reset_query(); $args = array('post_type' => 'custom_post_type', 'tax_query' => array( array( 'taxonomy' => 'custom_taxonomy', 'field' => 'slug', ...
66,242
<p>I have around 2000 custom posts. And 7 regular wp pages. I want to delete all those custom post without effecting the pages. I thought the easiest way would be to empty the custom post table but I dont know how to do it. I am familiar with DB operations but I dont know the schema of wp posts, so have no idea where t...
[ { "answer_id": 66255, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 1, "selected": false, "text": "<p>Posts, pages, and custom post types are all stored in the same table (usually <code>wp_posts</code> unless you set a ...
2012/09/25
[ "https://wordpress.stackexchange.com/questions/66242", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17911/" ]
I have around 2000 custom posts. And 7 regular wp pages. I want to delete all those custom post without effecting the pages. I thought the easiest way would be to empty the custom post table but I dont know how to do it. I am familiar with DB operations but I dont know the schema of wp posts, so have no idea where thes...
I used a custom page template to delete all the post from the wordpress database. Everytime I would go to this page it would delete 300 posts.The code for the page template is: ``` <?php // Get 300 custom post types pages, set the number higher if is not slow. $mycustomposts = get_posts( array( 'post_type' => 'movies...
66,245
<p>I'm making a homepage template for my theme and I want to call a plugin, namely royalslider. Surely </p> <pre><code>do_shortcode('[gallery id= "1"]'); </code></pre> <p>Should do the trick? </p>
[ { "answer_id": 66254, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 0, "selected": false, "text": "<p><code>do_shortcode()</code> returns output and doesn't print anything. I'm often caught by this. Often the soluti...
2012/09/25
[ "https://wordpress.stackexchange.com/questions/66245", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18635/" ]
I'm making a homepage template for my theme and I want to call a plugin, namely royalslider. Surely ``` do_shortcode('[gallery id= "1"]'); ``` Should do the trick?
Ensure you have the preload skin option selected in the Royalslider options
66,261
<p>It seem wp_query have the problem where it does not accept more than 1 negative value in author argument. for example:</p> <pre><code>$args = array('author=-2,-3,-4'); $newquery = WP_Query($args); </code></pre> <p>This grab everything else. Simply doesn't work.</p> <p>I found this <a href="http://core.trac.word...
[ { "answer_id": 66279, "author": "Ben HartLenn", "author_id": 6645, "author_profile": "https://wordpress.stackexchange.com/users/6645", "pm_score": 0, "selected": false, "text": "<p>I didn't realize it before, but it seems that you currently can't exclude multiple authors posts using WP_Q...
2012/09/25
[ "https://wordpress.stackexchange.com/questions/66261", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14728/" ]
It seem wp\_query have the problem where it does not accept more than 1 negative value in author argument. for example: ``` $args = array('author=-2,-3,-4'); $newquery = WP_Query($args); ``` This grab everything else. Simply doesn't work. I found this [trac](http://core.trac.wordpress.org/ticket/16854), but seem ...
You are right, it is not possible to pass an array with author IDs to exclude them. The reason is in `wp-includes/query.php` at [line 2294 - 2298](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/query.php#L2294) ``` if ( strpos($q['author'], '-') !== false ) { $eq = '!='; $andor = 'AND'; $q['author...
66,278
<p>I want to give linebreak on Wordpress theme's description in <code>style.css</code> (the one in here):</p> <pre><code>/* Theme Name: Theme URI: Description: Author: Author URI: Version: Tags: */ </code></pre> <p>But it appears the formatting doesn't allow any linebreak. When I tried writing on the line below...
[ { "answer_id": 66280, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>Is it not possible to add linebreaks in Wordpress theme's description?</p>\n</blockquote>\n\n<p>No.<...
2012/09/25
[ "https://wordpress.stackexchange.com/questions/66278", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13291/" ]
I want to give linebreak on Wordpress theme's description in `style.css` (the one in here): ``` /* Theme Name: Theme URI: Description: Author: Author URI: Version: Tags: */ ``` But it appears the formatting doesn't allow any linebreak. When I tried writing on the line below it, the text won't appear. I tried a...
> > Is it not possible to add linebreaks in Wordpress theme's description? > > > No. Sorry, to say - the question is valid, but I can't come up with a longer answer. Wouldn't make sense to explain the internals on this topic :)
66,284
<p>I am trying to submit form data to the database then send the client over to paypal which will use IPN to send a response back.</p> <p>Right now I have the form submitting to the database, I have the IPN working, my problem is the redirecting part. I want it all to be done in with the click of one button...</p> <p...
[ { "answer_id": 66286, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 0, "selected": false, "text": "<p>Indeed there is a simple solution. I assume you're doing the form processing and attempting to redirect in your tem...
2012/09/26
[ "https://wordpress.stackexchange.com/questions/66284", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16500/" ]
I am trying to submit form data to the database then send the client over to paypal which will use IPN to send a response back. Right now I have the form submitting to the database, I have the IPN working, my problem is the redirecting part. I want it all to be done in with the click of one button... My form just sub...
Not sure how I ran into this question one year later, but since it is unanswered... Instead of self-submitting the form and then redirecting to Paypal, you can instead have the paypal url as your form's action, but use Ajax to save the form data before the form is submitted to Paypal. You can also use the Ajax respons...
66,291
<p>I am looking for a method to hide or remove WordPress from the login options in Jetpack Comments.</p> <p>I have tried adding <code>a#postas-wordpress {display:none !important}</code> to the theme's style.css, but no luck.</p> <p>Here is a screenshot of the default comment form with Jetpack Comments enabled.</p> <...
[ { "answer_id": 66749, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 1, "selected": false, "text": "<p>Have you tried </p>\n\n<pre><code>&lt;style type=\"text/css\" title=\"text/css\"&gt;\na#postas-wordpress {dis...
2012/09/26
[ "https://wordpress.stackexchange.com/questions/66291", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14558/" ]
I am looking for a method to hide or remove WordPress from the login options in Jetpack Comments. I have tried adding `a#postas-wordpress {display:none !important}` to the theme's style.css, but no luck. Here is a screenshot of the default comment form with Jetpack Comments enabled. ![Wordpress Jetpack Comments form...
Expanding on Shines good find that its an iframe, i came up with this: If you can get a HTML element in next to the iframe (so that its a sibling to the iframe) you could make the parent and the iframe position relative and this new element (we can call the new element blockie) position absolute. now make sure that th...
66,309
<p>I want to display a different menu depending whether a user is logged into the CMS or not.</p> <p>I'm using this for my menu:</p> <pre><code>&lt;?php if ( is_user_logged_in() ) { $args = array( 'depth' =&gt; 1, 'show_date' =&gt; '', 'date_format' =&gt; get_option('date_format'), 'child_o...
[ { "answer_id": 66749, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 1, "selected": false, "text": "<p>Have you tried </p>\n\n<pre><code>&lt;style type=\"text/css\" title=\"text/css\"&gt;\na#postas-wordpress {dis...
2012/09/26
[ "https://wordpress.stackexchange.com/questions/66309", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
I want to display a different menu depending whether a user is logged into the CMS or not. I'm using this for my menu: ``` <?php if ( is_user_logged_in() ) { $args = array( 'depth' => 1, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' =...
Expanding on Shines good find that its an iframe, i came up with this: If you can get a HTML element in next to the iframe (so that its a sibling to the iframe) you could make the parent and the iframe position relative and this new element (we can call the new element blockie) position absolute. now make sure that th...
66,324
<p>How to assign parent page template to its child pages dynamically?</p>
[ { "answer_id": 66325, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 2, "selected": false, "text": "<p>Paste following code to your theme's <code>functions.php</code>:</p>\n\n<pre><code>add_action('save_post','c...
2012/09/26
[ "https://wordpress.stackexchange.com/questions/66324", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20848/" ]
How to assign parent page template to its child pages dynamically?
Paste following code to your theme's `functions.php`: ``` add_action('save_post','changeTemplateOnSave'); function changeTemplateOnSave(){ global $post; $curr_tmp = get_post_meta($post->ID, '_wp_page_template', true); $parent_tmp = get_post_meta($post->post_parent, '_wp_page_template', true); if($post-...
66,329
<p>I'm building a new design into WP and so technically it is a theme, however it is only a design for one site and won't be a theme anyone can use and hence I don't want to bother with internationalization.</p> <p>I have noticed WP makes use of internationalization in many functions by passing in the <code>textdomain...
[ { "answer_id": 66325, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 2, "selected": false, "text": "<p>Paste following code to your theme's <code>functions.php</code>:</p>\n\n<pre><code>add_action('save_post','c...
2012/09/26
[ "https://wordpress.stackexchange.com/questions/66329", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1839/" ]
I'm building a new design into WP and so technically it is a theme, however it is only a design for one site and won't be a theme anyone can use and hence I don't want to bother with internationalization. I have noticed WP makes use of internationalization in many functions by passing in the `textdomain` via functions...
Paste following code to your theme's `functions.php`: ``` add_action('save_post','changeTemplateOnSave'); function changeTemplateOnSave(){ global $post; $curr_tmp = get_post_meta($post->ID, '_wp_page_template', true); $parent_tmp = get_post_meta($post->post_parent, '_wp_page_template', true); if($post-...
66,338
<p>I currently display a URL from a custom meta box, but wanted to add a conditional check, so that if nothing has been entered, not to display the link text.</p> <pre><code>&lt;a target="_blank" href="&lt;?php $urlbox = get_url_desc_box(); echo $urlbox[0]; ?&gt;"&gt;Visit Website &amp;raquo;&lt;/a&gt; </code></pre> ...
[ { "answer_id": 66332, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>Wordpress is PHP, so look for where it's sending something like:</p>\n\n<pre><code>header(\"HTTP/1.0 404 Not Found...
2012/09/26
[ "https://wordpress.stackexchange.com/questions/66338", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20853/" ]
I currently display a URL from a custom meta box, but wanted to add a conditional check, so that if nothing has been entered, not to display the link text. ``` <a target="_blank" href="<?php $urlbox = get_url_desc_box(); echo $urlbox[0]; ?>">Visit Website &raquo;</a> ``` At the moment, even when nothing is added to ...
You can either add custom rewrites to your pages. Or on the top of the template files that wrap your other pages just output `header('HTTP/1.1 200 OK');`.
66,339
<p>I have a pretty common loop:</p> <pre><code>global $wp_query, $wpdb; if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'template_parts/content' ,get_post_format() ); } } else { get_template_part( 'no_results' ); } </code><...
[ { "answer_id": 66340, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>Actually it's pretty easy:</p>\n\n<pre><code>( $wpse_counter = count( $wp_query-&gt;posts ) ) &amp;&amp; ++$GLOBALS...
2012/09/26
[ "https://wordpress.stackexchange.com/questions/66339", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/385/" ]
I have a pretty common loop: ``` global $wp_query, $wpdb; if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'template_parts/content' ,get_post_format() ); } } else { get_template_part( 'no_results' ); } ``` Now I need to ad...
another possibility: ``` if( $wp_query->current_post < $wp_query->post_count-1 ) echo '<hr />'; ```
66,366
<p>When looking through WordPress snippets/tutorials/plugins I often see <code>add_action()</code> and <code>add_filter()</code> being placed before the function is declared:</p> <pre><code>add_action( 'publish_post', 'email_friends' ); function email_friends( $post_ID ) { $friends = 'bob@example.org, susie@exampl...
[ { "answer_id": 66368, "author": "OriginalEXE", "author_id": 16710, "author_profile": "https://wordpress.stackexchange.com/users/16710", "pm_score": 3, "selected": false, "text": "<p>There is no real difference actually, I for example prefer to follow first scenario, because it's neater t...
2012/09/26
[ "https://wordpress.stackexchange.com/questions/66366", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19379/" ]
When looking through WordPress snippets/tutorials/plugins I often see `add_action()` and `add_filter()` being placed before the function is declared: ``` add_action( 'publish_post', 'email_friends' ); function email_friends( $post_ID ) { $friends = 'bob@example.org, susie@example.org'; mail( $friends, "sally's ...
It is easier to read: **When** is **what** called? If you are debugging a hook you can immediately see if you have to read the function or not: If it is not your hook, you can skip the code. In my themes and plugins I combine all registrations for actions, filters and shortcodes at the top *and* I add the hook to the ...
66,384
<p>I am trying to add the most recent post from another Wordpress database (on the same server in all actuality), but am getting the following error:</p> <p><code>Fatal error: Call to undefined method wpdb::query_posts() in /var/www/site/wp-content/themes/custom/footer.php on line 68</code></p> <p>Here is the code:</...
[ { "answer_id": 66412, "author": "doublesharp", "author_id": 20880, "author_profile": "https://wordpress.stackexchange.com/users/20880", "pm_score": 3, "selected": true, "text": "<p>There is now, I just posted a plugin that I wrote to do validation for Advanced Custom Fields to the Wordpr...
2012/09/26
[ "https://wordpress.stackexchange.com/questions/66384", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20866/" ]
I am trying to add the most recent post from another Wordpress database (on the same server in all actuality), but am getting the following error: `Fatal error: Call to undefined method wpdb::query_posts() in /var/www/site/wp-content/themes/custom/footer.php on line 68` Here is the code: ``` <!-- .entry-content --> ...
There is now, I just posted a plugin that I wrote to do validation for Advanced Custom Fields to the Wordpress repository. It lets you do server side validation using either PHP code or regex, jQuery masked inputs, as well as unique value settings. <http://wordpress.org/extend/plugins/validated-field-for-acf/>
66,408
<p>I am a loss here since I have looked at dozens of tutorials and posts all over the internet on how to get the slug for a taxonomy and nothing I try seems to work. The taxonomy shows up fine when I want to edit the post and everything seems to be working fine, however I cannot seem for the life of me to get Wordpress...
[ { "answer_id": 67399, "author": "rgaspary", "author_id": 20877, "author_profile": "https://wordpress.stackexchange.com/users/20877", "pm_score": 0, "selected": false, "text": "<p>Here's my answer:</p>\n\n<pre><code>&lt;ul&gt;\n &lt;?php\n $post = 'projec...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66408", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20877/" ]
I am a loss here since I have looked at dozens of tutorials and posts all over the internet on how to get the slug for a taxonomy and nothing I try seems to work. The taxonomy shows up fine when I want to edit the post and everything seems to be working fine, however I cannot seem for the life of me to get Wordpress to...
I would not use `query_posts` and instead use `post_class` and a new `WP_Query` object. to insert the taxonomy slugs. This is more "future proof" and you can put it in a plugin to keep the same functionality across themes. This works the same exact way as what you're doing (`get_the_terms`, etc), but it keeps a lot of...
66,411
<p>I am currently using woocommerce and would like to redirect none logged in users to the home page, however i am having a little trouble determining where i should implements this</p> <p>I have done research and determined that using the is_user_logged_in() i can see if the user is logged in.</p> <p>I tryed impleme...
[ { "answer_id": 66433, "author": "Kyle", "author_id": 18066, "author_profile": "https://wordpress.stackexchange.com/users/18066", "pm_score": 1, "selected": true, "text": "<p>You are going to want to insert your code at the top of the page templates for the Woo pages you would like the re...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17608/" ]
I am currently using woocommerce and would like to redirect none logged in users to the home page, however i am having a little trouble determining where i should implements this I have done research and determined that using the is\_user\_logged\_in() i can see if the user is logged in. I tryed implementing in the w...
You are going to want to insert your code at the top of the page templates for the Woo pages you would like the redirect to affect rather than the functions file. So for example if you want to redirect users when they try to access an individual product page you could put it at the top of the plugins->woocommerce->temp...
66,416
<p>How to hide (or not to show, better said) trackbacks on wp-admin/edit-comments.php page?</p> <p>I want to hide the comments with no email (also known as trackbacks) and comments with a specific email from the edit-comments.php page.</p>
[ { "answer_id": 66425, "author": "janw", "author_id": 10911, "author_profile": "https://wordpress.stackexchange.com/users/10911", "pm_score": -1, "selected": false, "text": "<p>To only show comments on the comments page.<br>\nAbove the list there are 2 dropdowns one has the option to only...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20885/" ]
How to hide (or not to show, better said) trackbacks on wp-admin/edit-comments.php page? I want to hide the comments with no email (also known as trackbacks) and comments with a specific email from the edit-comments.php page.
While this is not impossible, this is very likely to have ton of edge cases and backfire in some. In a nutshell comments are retrieved with comment query, which can be adjusted with something like this (if in admin and comment type not specified then only fetch normal comments): ``` add_action( 'pre_get_comments', 'ex...
66,427
<p>I need to create a single post with title, content and excerpt with this command as it's described in the utility documentation. Could you please show me an example of how to use it? I couldn't find nor in official documentation neither on Google. Thanks!</p>
[ { "answer_id": 66547, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 2, "selected": false, "text": "<p>If you look at <a href=\"https://github.com/wp-cli/wp-cli/blob/master/src/php/wp-cli/commands/internals/post.php\" rel...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66427", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1100/" ]
I need to create a single post with title, content and excerpt with this command as it's described in the utility documentation. Could you please show me an example of how to use it? I couldn't find nor in official documentation neither on Google. Thanks!
If you type `wp help post create` you will get all the info you need. Example: ``` wp post create --post_type=page --post_status=publish --post_title='A new page' ```
66,432
<p>I am trying to make a frontend product editor for WooCommerce, and have a loop that returns all of the products for the current user. I am trying to use gravity forms as the editor, so a single gravity form is displayed and populated for each product. However, I am not sure how to handle naming the function so it is...
[ { "answer_id": 66434, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 0, "selected": false, "text": "<p>Don't add the filter inside the loop. Put the code in <code>functions.php</code>, and use <code>get_pos...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66432", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18066/" ]
I am trying to make a frontend product editor for WooCommerce, and have a loop that returns all of the products for the current user. I am trying to use gravity forms as the editor, so a single gravity form is displayed and populated for each product. However, I am not sure how to handle naming the function so it is no...
Before continuing, please read this: <http://www.slideshare.net/andrewnacin/you-dont-know-query-wordcamp-netherlands-2012> It's by a core WordPress developer and you should consider it required reading. You should never use `query_posts`, and it's important to understand how to use loops correctly. That presentation ...
66,453
<p>I have read through multiple questions here on StackExchange that concern WordPress scaling and the common opinion is that WordPress is indeed highly scalable provided you have the infrastructure to support it. However, all opinions point and talk about the database scaling.</p> <p>However, I must ask out of curios...
[ { "answer_id": 66460, "author": "Alex", "author_id": 20908, "author_profile": "https://wordpress.stackexchange.com/users/20908", "pm_score": 3, "selected": false, "text": "<p>As cool as infinite scalability would be, it is not really necessary to code into most projects. </p>\n\n<p>That ...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9094/" ]
I have read through multiple questions here on StackExchange that concern WordPress scaling and the common opinion is that WordPress is indeed highly scalable provided you have the infrastructure to support it. However, all opinions point and talk about the database scaling. However, I must ask out of curiosity as to ...
If `INT` is set to `UNSIGNED`, allowing only non-negative integers, your value range is from `0` to `4294967295`. Thats... ``` 4,294,967,295 (4 billion +). ``` ...for the given table. Just to put things into perspective. Only through poor management and unnecessary incrementation would you exhaust that range, say ...
66,455
<p>How can I change the order of posts in the admin dashboard, so they display alphabetically according to title, rather than latest first?</p>
[ { "answer_id": 66467, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 3, "selected": false, "text": "<p><strong>Ah, click that little title thingy to toggle alphabetical sorting....</strong></p>\n\n<p><img src=\"h...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66455", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
How can I change the order of posts in the admin dashboard, so they display alphabetically according to title, rather than latest first?
If you don't wish to always click the "Title" column to sort your posts by title, you can place this code in either your currently active WordPress theme's `functions.php` file, or within a plugin. This will automatically always sort your posts for you, so you don't have to click the title column every time. You can u...
66,456
<p>Is there any way to make all requests to any subdomain load the same Wordpress website e.g. user1.example.com, user2.example.com and user3.example.com all load the same website, but with the links pointing to the current subdomain? </p> <p>I'd like to keep mostly the same content across the different websites. The ...
[ { "answer_id": 66467, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 3, "selected": false, "text": "<p><strong>Ah, click that little title thingy to toggle alphabetical sorting....</strong></p>\n\n<p><img src=\"h...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66456", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/449/" ]
Is there any way to make all requests to any subdomain load the same Wordpress website e.g. user1.example.com, user2.example.com and user3.example.com all load the same website, but with the links pointing to the current subdomain? I'd like to keep mostly the same content across the different websites. The only diffe...
If you don't wish to always click the "Title" column to sort your posts by title, you can place this code in either your currently active WordPress theme's `functions.php` file, or within a plugin. This will automatically always sort your posts for you, so you don't have to click the title column every time. You can u...
66,457
<p>I get an undefined Offset message with this Query. Can anyone Help?</p> <pre><code>$terms = get_the_terms( $post-&gt;ID , 'filters', 'string'); $term_ids = wp_list_pluck($terms,'term_id'); $second_query = new WP_Query( array( 'post_type' =&gt; 'portfolio', 'tax_query' =&g...
[ { "answer_id": 66467, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 3, "selected": false, "text": "<p><strong>Ah, click that little title thingy to toggle alphabetical sorting....</strong></p>\n\n<p><img src=\"h...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20907/" ]
I get an undefined Offset message with this Query. Can anyone Help? ``` $terms = get_the_terms( $post->ID , 'filters', 'string'); $term_ids = wp_list_pluck($terms,'term_id'); $second_query = new WP_Query( array( 'post_type' => 'portfolio', 'tax_query' => array( ...
If you don't wish to always click the "Title" column to sort your posts by title, you can place this code in either your currently active WordPress theme's `functions.php` file, or within a plugin. This will automatically always sort your posts for you, so you don't have to click the title column every time. You can u...
66,475
<p>I am trying to adapt the Wordpress loop to style posts differently in rows that get infinitely smaller until all posts are displayed</p> <p>The concept here is to display posts in rows</p> <ul> <li>first row 1 post</li> <li>second row 2 posts</li> <li>third row 3 posts</li> <li>fourth row 4 posts</li> <li>fifth r...
[ { "answer_id": 66496, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>It's basically only some math, but you can use <code>$wp_query</code> properties perfectly for that case:</p>\n\n<h...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66475", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20913/" ]
I am trying to adapt the Wordpress loop to style posts differently in rows that get infinitely smaller until all posts are displayed The concept here is to display posts in rows * first row 1 post * second row 2 posts * third row 3 posts * fourth row 4 posts * fifth row 5 posts * sixth row 6 posts * seventh row 7 po...
It's basically only some math, but you can use `$wp_query` properties perfectly for that case: Increment --------- ``` global $wp_query; if ( have_posts() ) { while ( have_posts() ) { the_post(); printf( '<div %s>%s</div>', get_post_class( "style-{$wp_query->current_po...
66,479
<p>I've created a custom post type called <code>'publications'</code> and a custom taxonomy called <code>'topics'</code>. I'm also using the standard taxonomy of <code>'category'</code>.</p> <p>My Custom Query makes sure that it fetches ALL <code>'publications'</code> that are in the correct <code>'category'</code> bu...
[ { "answer_id": 66923, "author": "Jonathan", "author_id": 17872, "author_profile": "https://wordpress.stackexchange.com/users/17872", "pm_score": 2, "selected": false, "text": "<p>Just looking at the term_taxonomy table, you are selecting everything correctly, but the last part:</p>\n\n<p...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66479", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20914/" ]
I've created a custom post type called `'publications'` and a custom taxonomy called `'topics'`. I'm also using the standard taxonomy of `'category'`. My Custom Query makes sure that it fetches ALL `'publications'` that are in the correct `'category'` but I'd like it to also `ORDER BY` the additional `'topics'` taxono...
Finally, I have managed to make this work. I've found the holy grail of ordering custom post types by a custom taxonomy, with pagination. The code isn't pretty but it works. My method was to forget about SQL queries and to just select ALL the custom posts that matched the correct Category and the correct Custom Post T...
66,480
<p>I'm working with a Genesis Based Theme and I'd like build a Page/ Child Page menu structure. That part I can do with the help of some code produced by Bill Erickson.</p> <p>Essentially what I'm trying to do is create a menu above content on pages with child pages. Then, in the left sidebar, have navigation for chil...
[ { "answer_id": 66808, "author": "Alex V.", "author_id": 20910, "author_profile": "https://wordpress.stackexchange.com/users/20910", "pm_score": 1, "selected": false, "text": "<p>Well, I'm afraid I never did work out the code to this. What I did find is a pair of plugins that accomplish w...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20910/" ]
I'm working with a Genesis Based Theme and I'd like build a Page/ Child Page menu structure. That part I can do with the help of some code produced by Bill Erickson. Essentially what I'm trying to do is create a menu above content on pages with child pages. Then, in the left sidebar, have navigation for children pages...
Well, I'm afraid I never did work out the code to this. What I did find is a pair of plugins that accomplish what I'm looking to do. List sub pages of the same level as the current sub page/child/grandchild page and then be able to exclude certain pages from showing up. * <http://wordpress.org/extend/plugins/child-pag...
66,498
<p>The <a href="http://codex.wordpress.org/Function_Reference/add_menu_page" rel="noreferrer"><code>add_menu_page</code> documentation</a> says to pass the menu title as the second parameter:</p> <pre><code>add_menu_page('Page Title', 'Menu Title', ...); </code></pre> <p>When adding more pages later via <a href="http...
[ { "answer_id": 66499, "author": "Michael Lewis", "author_id": 20149, "author_profile": "https://wordpress.stackexchange.com/users/20149", "pm_score": 8, "selected": true, "text": "<p>You can make the 'slug' for the submenu page equal that of the top level page, and they'll point to the s...
2012/09/27
[ "https://wordpress.stackexchange.com/questions/66498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12399/" ]
The [`add_menu_page` documentation](http://codex.wordpress.org/Function_Reference/add_menu_page) says to pass the menu title as the second parameter: ``` add_menu_page('Page Title', 'Menu Title', ...); ``` When adding more pages later via [`add_submenu_page`](http://codex.wordpress.org/Function_Reference/add_submenu...
You can make the 'slug' for the submenu page equal that of the top level page, and they'll point to the same place: ``` add_action('admin_menu', 'my_menu_pages'); function my_menu_pages(){ add_menu_page('My Page Title', 'My Menu Title', 'manage_options', 'my-menu', 'my_menu_output' ); add_submenu_page('my-menu...
66,512
<p>Haven't found a useful answer for this. I am aware of the conflict issues and all the problems this may cause, I'm curious if it's POSSIBLE not SUGGESTED. This will require WP rewrites, I know this much. </p> <p>Basically, let's say we have a CPT of "events". I want to have a single event's page have the URL <a...
[ { "answer_id": 75993, "author": "Bartosz", "author_id": 24771, "author_profile": "https://wordpress.stackexchange.com/users/24771", "pm_score": 3, "selected": false, "text": "<p>That's how you can do first part of the job - get rid o CPT slug in post link (eg. news post type).</p>\n\n<pr...
2012/09/28
[ "https://wordpress.stackexchange.com/questions/66512", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2026/" ]
Haven't found a useful answer for this. I am aware of the conflict issues and all the problems this may cause, I'm curious if it's POSSIBLE not SUGGESTED. This will require WP rewrites, I know this much. Basically, let's say we have a CPT of "events". I want to have a single event's page have the URL <http://domain.c...
That's how you can do first part of the job - get rid o CPT slug in post link (eg. news post type). ``` function df_custom_post_type_link( $post_link, $id = 0 ) { $post = get_post($id); if ( is_wp_error($post) || 'news' != $post->post_type || empty($post->post_name) ) return $post_link; ...
66,524
<p>I´m creating a child theme for Twenty Twelve v1.0 and I want to remove the Open Sans font. </p> <p>Open Sans is added in Twenty Twelve´s functions.php:</p> <pre><code>wp_enqueue_style( 'twentytwelve-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); </code></pre> <p>I´v...
[ { "answer_id": 66525, "author": "Mattvic", "author_id": 7584, "author_profile": "https://wordpress.stackexchange.com/users/7584", "pm_score": 5, "selected": true, "text": "<p>Found the answer <a href=\"https://wordpress.stackexchange.com/questions/64867/remove-a-script-from-a-template-fi...
2012/09/28
[ "https://wordpress.stackexchange.com/questions/66524", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7584/" ]
I´m creating a child theme for Twenty Twelve v1.0 and I want to remove the Open Sans font. Open Sans is added in Twenty Twelve´s functions.php: ``` wp_enqueue_style( 'twentytwelve-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null ); ``` I´ve tried to deregister/dequeue the...
Found the answer [here](https://wordpress.stackexchange.com/questions/64867/remove-a-script-from-a-template-file-using-wp-dequeue-script?rq=1): > > Script dequeuing calls should be added to the wp\_print\_scripts action > hook(..). This is because scripts are typically enqueued on the > wp\_enqueue\_script hook, w...