question
stringlengths
0
34.8k
answer
stringlengths
0
28.3k
title
stringlengths
7
150
forum_tag
stringclasses
12 values
I'm looking for the simplest way to redirect a password protected page, to another page after entering the password. E.g. <code> &lt;?php if ( is_page('name-of-page') &amp;&amp; ! post_password_required() ) { wp_redirect( home_url() ); exit; } ?&gt; </code> Using wp_redirect is triggering a 'headers already sent error'...
Tom J Nowell confirmed what was happening. Inserting <code> wp_redirect </code> in a template causes the page either to partially load or not load at all. It needed to be placed before the opening <code> &lt;html&gt; </code> to work as it would load everything before <code> &lt;/head&gt; </code> then stop.
Redirect a password protected page?
wordpress
I added the below code to the <code> function.php </code> of a .po file and finished localization and edited the <code> webconfig.php </code> to add Arabic language but nothing happened. I want to know what should happen. Will the site include the new language - in my situation Arabic, or what? Now the website is in En...
First, read this Codex page about translating WordPress. You have to create a language file to put into your language directory, do this by following the next steps: I assume you want to use poedit since you talk about a <code> .po </code> file download poedit File > new catalog In the first tab, fill in the fields, th...
What is the purpose of adding a .po file?
wordpress
According to the codex Themes are required to use theme-slug (or a reasonable facsimile) as textdomain for translation Does this mean that my theme needs to include a textdomain even if my theme doesn't support translation? ... and also is there any harm in including a textdomain in <code> style.css </code> if there ar...
If your code, be it a theme or a plugin, does not support translation, then don’t use the translation functions. And if you don’t use these functions, you cannot use a text domain. :) There is a very common error that looks like this: <code> echo __( 'Portfolio' ); </code> Portfolio is not part of WordPress’ core strin...
Do I need to include a textdomain if my theme doesn't support translation?
wordpress
I'm using wp_list_pages to create a navigation menu. I've run into a challenge with the menu order, though, and I am trying to figure out a way to take more control over the order of the menu. Is it possible to customize the order of the wp_list_pages output using a Walker? For example, I'd like to check if a given pag...
<code> wp_list_pages( $args ) </code> calls <code> get_pages( $args ) </code> . You can filter the <code> get_pages() </code> output with a filter on <code> get_pages </code> . Let’s say you call <code> wp_list_pages() </code> like this: <code> wp_list_pages( array( 'please_filter_me' =&gt; TRUE ) ); </code> You can so...
wp_list_pages - Using a Walker to customize output order
wordpress
I have a custom tag-like taxonomy called PEOPLE registered to all post types - both the default and custom ones. I have created a template for a single term named taxonomy-people.php and I'm intending to use it to describe a specific term and query each post type for instances of that term. I have almost managed to do ...
Your code, when working, will consume sooo much resources. When implemented in this way - throught custom page template, WordPress will call for a content of that page (1 query) and after that it will call a query for each custom post type - another 4 queries. That's a lot, really. I would suggest you to take the advan...
Listing all custom post types using a specific term on the said term's template page, in groups
wordpress
I've used a custom post type for one of my website. Custom post type contains scratch card data along with some custom fields. I've developed an android application to manage those items from android device. In the android app, I want to keep search feature which will help admin users to search card numbers to manage t...
You can use either search parameter of wp_query : <code> Code $args = array("post_type" =&gt; "mytype", "s" =&gt; $title); $query = get_posts( $args ); </code> Or you can get posts based on title throught wpdb class : <code> global $wpdb; $posts = $wpdb-&gt;get_results( $wpdb-&gt;prepare("SELECT * FROM $wpdb-&gt;posts ...
Query by post title
wordpress
I have an odd problem I'm hoping the group can help with. The problem is this: I have a few situations where I load the Wordpress environment without the overhead of the GUI (stackexchange-url ("details")) I am able to do this in most environments without a problem but a few (two laptops to be precise) refuse to load W...
I accidentally stumbled into the answer today when I forgot to turn on my MAMP managed mysql server. At this juncture it pointed me to the critical difference. This answer is phrased for anyone running MAMP but potentially has broader applicability (certainly LAMP, WAMP, etc.); if you're experiencing the same problem i...
DB access blocked when initializing WP externally
wordpress
Hy, i want to count years of an actor. The date that actor is born is stored in a custom field. <code> $date = get_field('data_nasterii'); </code> Date stored in custom field is : yymmdd How can i stick bouth togeder to make it work. <code> &lt;?php //date in mm/dd/yyyy format; or it can be in other formats as well $bi...
Assuming that your date format - for whatever reason - really is <code> yymmdd </code> instead of being set to what you defined in the admin settings section: There's the native PHP function <code> date_parse_from_format() </code> that you can use in conjunction with the core setting. Just add the following plugin and ...
How can i put a custom field inside this php
wordpress
My site uses a lot of categories and tags for author selection in the back-end. To make it more user friendly for authors I need to arrange the categories and post tags in numerous metaboxes for selection on the post edit screen. I would like to display some selected categories and their children in one metabox for aut...
Yup! Just register a new taxonomy in your functions.php and it'll show up in your post editor. <code> function my_custom_taxonomy(){ $args = array( 'settings' =&gt; 'here' ); register_taxonomy('Authors', 'post', $args); } add_action('init', 'my_custom_taxonomy'); </code> http://codex.wordpress.org/Function_Reference/re...
Filter categories/tags to display in multiple metaboxes for selection in back-end
wordpress
AFAIK a <code> style.css </code> for Wordpress needs some comments at the top to be properly recognized, like: <code> /* Theme Name: Cool Theme Theme URI: http://www.example.com Description: Super cool theme */ </code> Are there any restrictions regarding content? I've also seen people writing stuff in there like <code...
There is no reason to add something not listed in WP_Theme class <code> $file_headers </code> array because it simply will not be recognized. <code> private static $file_headers = array( 'Name' =&gt; 'Theme Name', 'ThemeURI' =&gt; 'Theme URI', 'Description' =&gt; 'Description', 'Author' =&gt; 'Author', 'AuthorURI' =&gt...
Wordpress CSS head info - contents, expansions?
wordpress
I have a WordPress 3.5.1 + nginx configuration. Its nginx configuration is this: <code> server { root /mysite/public_html; server_name wp.mysite; location / { try_files $uri $uri/ /index.php; index index.php index.html index.htm; } location ~ \.php(.*)$ { try_files $uri =404; include /etc/nginx/fastcgi_params; if ($uri...
It turns out that it's the <code> require('../wp-blog-header.php'); </code> part who caused the HTTP 404 error. I replaced the header code with: <code> status_header(200); nocache_headers(); </code> Both are part of WordPress API. And the problem went away. I found this solution from: http://wordpress.org/support/topic...
Mysterious HTTP 404 header in my own scripts
wordpress
Hi I am using the yootheme master collection and I wish to get a list of 10 permalinks from this custom post catagory but at the moment I can only get 1 to show. How do I do this properly? Cheers <code> &lt;div id="rec-p" style="width:80%; height:100%; border:2px dotted red; float:left; "&gt; &lt;?php if (have_posts())...
As I've mentioned in the comment to the question, your loop is incomplete. You need <code> while </code> loop to iterate through posts and <code> the_post() </code> function to get those posts one by one: <code> &lt;?php // if there are posts if ( have_posts() ) : // iterate through all posts while ( have_posts() ) : /...
Get a list of post titles and links from yootheme master theme
wordpress
Submitting a post comment without message leads to a white page with a clean WP error message "ERROR: please type a comment." Is it possible to achieve the same thing for input fields from a custom form? For instance, I've got my own custom contact page template containing a number of input fields, some of them I want ...
I believe yo are looking for <code> wp_die </code> which will Kill WordPress execution and display HTML message with error message. But the codex says: It is not recommended to call this function very often and try to handle as many errors as possible silently.
Making an input field required from WP's perspective
wordpress
Maybe this is too simple question, but I've tried to find out the info by myself. How can I remove margins (all: left, top, right, bottom) for Twenty Twelve theme? This is what I mean:
I think you mean these class definitions in style.css: <code> /* =Media queries -------------------------------------------------------------- */ /* Minimum width of 600 pixels. */ @media screen and (min-width: 600px) { ...cut... .site { margin: 0 auto; max-width: 960px; max-width: 68.571428571rem; overflow: hidden; } ...
Twenty Twelve theme: remove margins
wordpress
I recently updated my WordPress site into the latest WordPress version, and i added a code to my <code> functions.php </code> that would add a capability to subscriber to upload using WordPress media upload. I successfully remove the media library tabs on the later version of WordPress but when I updated the version it...
If you want to hide the Media Library submenu: you can do it via the <code> admin_menu </code> action: <code> function wpse85351_hide_submenus() { if(!current_user_can('edit_posts')){ global $submenu; unset($submenu['upload.php'][5]); // hide the Media Library } } add_action('admin_menu', 'wpse85351_hide_submenus'); </...
remove other tabs in new wordpress media gallery
wordpress
I created a custom page template <code> movie-page.php </code> and a page <code> movie </code> in WP. The template shows fine when I visit site.com/movie/ I want to add <code> movie_id </code> as a query var. Here's my code: <code> add_filter('query_vars', 'poe_query_vars'); function poe_query_vars( $vars ) { $vars[] =...
When creating an internal rewrite rule, <code> $1 </code> should instead be <code> $matches[1] </code> .
Custom page template query_vars
wordpress
I've got a few special needs in terms of post formatting, but do not want (and cannot) break out of the standard Post Format paradigm per best practices. I've come up with a mapping of WordPress core types to my company's own nomenclature (e.g. show "chat" as "discussion"). I'd like to (from a UI perspective only) rena...
Yes, you can. You can hook right into gettext. The example provided below changes Publish button: <code> add_filter( 'gettext', 'binda_change_publish_button', 10, 2 ); function binda_change_publish_button( $translation, $text ) { //check if this is pizza add or edit page in administration global $pagenow, $typenow; if ...
Is it possible to filter the display name for post formats for display in the Formats meta box?
wordpress
I am creating a theme where user can save custom styles from theme customizer through settings API. Those style info are saved in options table as serialized data. When Custom skin is active I will have to print those css styles in the site. There are three route I might go about it. Printing custom styles on header ar...
When your users really need 30 lines of custom CSS, your theme is flawed. Create a set of predefined styles instead (dark and light scheme, sans and serif fonts etc.) and prepare your main stylesheet for these cases. You can hook into <code> body_class </code> then and add the classes you need to get these styles. Adju...
How to work with custom styles saved in theme option?
wordpress
Running WP 3.5.1 on a LEMP stack (over at Linode) ... I have a wp-content folder for a WP site along with a full backup of the database. The URL of the site was something like: test.example.com I want to get the site operational on my own server at: test.mydomain.com And once the site is finished and DNS changes take e...
There's a pretty good step by step on moving WordPress in the Codex. It is what I follow when changing domains. Moving the files is pretty straight-forward. It is the hard-coded references in the database that are tricky. However, serialized search and replace will take care of all database changes. I've used the Velve...
How to move existing Wordpress wp-content folder along with database to new server and new domain name?
wordpress
I'm using the following code in my plugin to display a <code> &lt;textarea&gt; </code> field on a page: <code> echo '&lt;textarea required="required" name="Message" class="textarea" cols="70" rows="10"&gt;'.esc_textarea($message).'&lt;/textarea&gt;'; </code> However, WordPress seems to be inserting <code> &lt;p&gt; </c...
Add a priority to push your function to the end of the hook queue. <code> add_action('the_content', 'my_plugin_content_hook', 1000); </code> Then, in your <code> get_special_content </code> function you will need to apply <code> wpautop </code> manually to the content to which you want it applied. <code> function get_s...
Disable formatting on textarea
wordpress
I need to remove the Edit link next to Publish immediately as I don't want my user to schedule the post. How can I achieve this? Thanks!
Here is one idea to hide the Edit link via CSS: <code> function wpse85434_hide_editlinks() { if(!current_user_can('manage_options')){ // only for non-admins echo "&lt;style&gt;.misc-pub-section .edit-timestamp{display:none !important;} &lt;/style&gt;"; } } add_action('admin_head-post.php','wpse85434_hide_editlinks'); a...
Remove "Edit Link" next to "Publish immediatley" when adding a new post
wordpress
I have built a Wordpress plugin that is based on jQuery and I am using <code> wp_enqueue_script('jquery'); </code> to make it all work. Let say the default version of jQuery loaded by Wordpress is 1.7.2, what would happen if the users installs a theme based on a different version of jQuery? What version of jQuery will ...
As other have mentioned , there is no great answer to this, ultimately you cannot control how other people write plugins/themes and there are no standards for naming <code> wp_enqueue_script </code> 's, though there probably should be. Also there is no current way to check if jQuery is loaded using <code> wp_enqueue_sc...
Plugin jQuery version VS Theme jQuery version: search for best practice
wordpress
I am using the following lines to check if the theme setting already exist or set but it's not working: <code> if (get_theme_mod('mysetting')==FALSE) { </code> Aside from get_theme_mod, how to really check if the theme setting is already set? Thanks.
Maybe <code> get_option </code> will do the trick http://codex.wordpress.org/Function_Reference/get_option
How to check if a certain theme option settings has already been set
wordpress
First of all, Multisite isn't what I'm looking for. I have 5 websites using Wordpress all on separate domains that I would like to enable user accounts for. I need user data to be shared across the entire network and when a user creates an account, they would have instant access to all other websites as well. What I'm ...
Ok, first of all, I feel like an idiot, although in my defense most of the articles that talk about this don't mention a very crutial detail in making this work. The answer is that you need to set permission for at least one admin in the database. This info can be found in the Codex here: http://codex.wordpress.org/Edi...
Whats the best way to share user data across multiple Wordpress websites?
wordpress
I hope this problem does not have too complicated of a solution. I also hope it isn't too easy so I don't feel like a fool for not figuring it out :) On my website, (Wordpress), I have Peter's redirect plugin that redirects users after login to their specified personal page (not profile.php). This is great. However, af...
Thank you so much for the responses. Using both of the ideas received I started to play a little with the code, although I was not sure what to do with them. I came up with a solution that works very well for me, I created a new template in my theme called 'redirect.php'. At the very beginning of the page template I in...
Redirect to current user page upon link click
wordpress
I have this idea where I would create a class that would take in a set of hook names then create them, for me to use when ever, and where ever. Currently the way to create a hook is we do something like: <code> function some_hook_name(){ do_action('some_hook_name'); } </code> And then from there we write some other fun...
Your proposal is OK - you can see this in action even in the WordPress itself. See admin-ajax.php where you can find this piece of code: <code> // Register core Ajax calls. if ( ! empty( $_GET['action'] ) &amp;&amp; in_array( $_GET['action'], $core_actions_get ) ) add_action( 'wp_ajax_' . $_GET['action'], 'wp_ajax_' . ...
Create hooks based on an array of hook names?
wordpress
I've got several custom widgets which are extended from WP_widget. Many of these have textarea fields. I'd like to be able to apply a special css class to certain of these textareas in order to convert them to rich text areas with a basic TinyMCE toolbar control. How involved is this to do? I'd like to implement a solu...
use the function wp_editor() to your textarea. This is the best and easy way, also usable fast forward.
Add tinymce to widget textareas
wordpress
Hy, im building a cinema site, in movie page i have a Custom Field that link's the actor page, when i add a movie and i link the actor, on the actor page i get the movie, now the problem is how can i add in this code the text "No movie by this actor", if no movie is selected i want to retrive automate That Text. To ret...
Something along these lines should work: <code> if ( $the_query-&gt;have_posts()){ while ( $the_query-&gt;have_posts() ) : $the_query-&gt;the_post(); echo '&lt;div class="actor-box-related"&gt;&lt;a class="actor-titlu" href="'; the_permalink(); echo '" title="'.get_the_title().'"&gt;'; ?&gt; &lt;img class="actor-img" s...
How to retrive the text : No movie by this actor
wordpress
Is there any way to evaluate the language a post/page is written in? I am building a multilingual site and am almost pulling my hair out trying to get the front-end navigation to take the chosen language into account. So far the polylang plugin http://wordpress.org/extend/plugins/polylang/ has worked fine for everythin...
The main language of a post should be saved in a post meta field. There is no way to detect that automatically. Even Google’s heuristics fail regularly with that. So add a custom field <code> lang </code> and check with … <code> $language = get_post_meta( get_the_ID(), 'lang', TRUE ); </code> … what language the post w...
detect the language a post is written in
wordpress
I have theme options saved as serialized data. And I have named the option name by getting theme name. <code> $theme = wp_get_theme(); $settings = sanitize_title($theme).'-options'; // do not change! </code> But when I am trying to pass the $settings variable with or without concatenation. It ends up with this fatal er...
Thanks to @chip_bennett to point it out! I registered the settings using settings api and I was trying to add the settings on customize api by the type of <code> theme_mod </code> that's why it was showing the error. After changing the <code> 'type' =&gt; 'theme_mod' </code> to <code> 'type' =&gt; 'option' </code> , it...
Unable to pass variable on theme cusomizer add_settings()
wordpress
Since I am new to wordpress plugin development I have been examining internal structure of many plugin's and I could find most of them doesnt fit any pattern and understanding how they works is pretty much difficult. I was wondering if there is more generalised way of plugin development, possibly with a framework, othe...
AFAIK, there's no framework official/standard framework, and there will be as many plugin development styles as there are shades of white in north pole. I'd say WordPress Coding Standards are a blueprint for a good style. You'll find lots of good examples and excellent coders here in WPSE. A nice starting point: stacke...
Is there any plugin development framework
wordpress
I am trying to create a medical website, where logged-in doctors can actually upload pdfs and other files (such as jpg) from the front-end in posts. Then, after reloading the page, the uploaded files should be retrieved within the same post, so other users can easily find the info, without any access to the back-end wh...
Yes, this can be done in WordPress. Check out http://wp.tutsplus.com/tutorials/allow-users-to-submit-images-your-site/ for some code examples. You will have to modify the logic to suit your needs of course, but the above link should get you pointed in the right direction.
Upload PDF and other files from the Front-End
wordpress
I'm using BuddyPress and need a certain block of code to show up on user role Store Owner profiles only. I'll be putting it in member_header.php, so it's just a template file. I've been digging for a long time now and just can't seem to figure this out. I found a way to target current user role, but that makes it show ...
I think you need to check if the displayed user has that role, try replacing <code> $user-&gt;ID </code> with <code> bp_displayed_user_id() </code> : <code> function my_setup_nav() { if ( user_can( bp_displayed_user_id(), 'store_owner' ) ) { // ... rest of your code } } </code>
Conditional based on the User Role of the Current Profile the user is viewing - BuddyPress
wordpress
I've already removed the Unattached link through functions.php, the last thing I need now is to remove the (Unattached) Attach from " Uploaded to " in Media Library . I've no clue about what code should I add in functions.php to get rid of it and it's hours I'm searching on the web... Help please...
It seems there is no other way than de-registering the column and building your own. The code of the custom column is adapted from <code> class-wp-media-list-table.php </code> . <code> add_filter( 'manage_upload_columns', 'columns_manage_wpse_85405' ); add_action( 'manage_media_custom_column', 'columns_display_wpse_854...
Remove (Unattached) Attach from "Uploaded to" in Media Library
wordpress
Using the the remove_menu_page function results in a really strange bug. By adding the code below in the functions.php file the integrated "Add media" widget starts to bug. <code> function remove_menu_pages() { // Remove admin menu pages that are not used remove_menu_page( 'link-manager.php' ); remove_menu_page( 'tools...
It's because you've hooked it to the wrong action, it should be <code> admin_menu </code> , not <code> admin_init </code> .
remove_menu_page breaks "Add media"
wordpress
I get the latest posts this way: <code> $args = array( 'numberposts' =&gt; '2' ); $recent_posts = wp_get_recent_posts( $args ); </code> Then I loop through them and get information about the post this way: <code> $recent_posts[0]["post_title"] </code> How can I get the date the post was published?
You can see everything returned via php's <code> var_dump </code> or <code> print_r </code> : <code> $recent_posts = wp_get_recent_posts(); echo '&lt;pre&gt;'; print_r( $recent_posts ); echo '&lt;/pre&gt;'; </code> This will reveal that the date is stored in <code> post_date </code> : <code> foreach( $recent_posts as $...
How to get date of post when using wp_get_recent_posts()?
wordpress
I am creating several custom post types, do I need to keep the register_post_type calls in functions.php? I would assume that this would only need to be run the once then removed, or do I need to keep the calls there?
Yes, you need to keep it within <code> functions.php </code> and within the <code> init </code> hook, as it will have to register each time. It's not like with roles, where you can add it once and it's saved in the database.
Do i need to keep register_post_type in functions.php?
wordpress
I see that there are lots of filters and things you can do to remove fields or modify them. I have found some useful ones on this site. I want to take it a step further because I want to do some things that there does not seem to be a filter for. Like removing the labels. At least I have not found one yet. I also need ...
That function is called directly in a theme, probably in <code> comments.php </code> . Remove the function call there, and use your own function with a different name. Be aware many plugins rely on the code in the native function. If you change too much, some plugin might break. You can edit the <code> label </code> el...
modifying the comment form
wordpress
I am trying to do a simple query to get the latest 5 posts into an unordered list, but this is only showing 1 result even though I have several posts. I even did an offset, but it shows the next post yet still 1 result. What am I doing wrong? <code> &lt;ul&gt; &lt;?php $the_query = new WP_Query('showposts=5'); ?&gt; &l...
<code> the_content_limit </code> does not exist in WordPress. You probably want something like <code> the_excerpt </code> . What's likely happening is your loop is working fine, but the call to an undefined function causes the program to error out, making it appear the the loop is not working. Look at the rendered HTML...
Why WP_Query('showposts=5') shows only 1 post?
wordpress
I was hoping to do all of this within the category.php template, with help from the functions.php if needed. If my setup is: <code> Parent 1 --Child 1 --Child 2 Parent 2 --Child 3 --Child 4 Parent 3 --Child 5 --Child 6 </code> ...and so on I would like to be able to do this: If I was viewing Parent 1 (or 2/3), it would...
Solved, thanks to nofearinc on the wp.org irc chat! :) https://gist.github.com/mpeshev/cb1cd3c56d06017b3d87 <code> &lt;?php $cat_id = get_query_var('cat'); if( ! empty( $cat_id ) ) { $category = get_category( $cat_id, ARRAY_A ); if( ! empty( $category ) ) { // parent category if( $category['parent'] === '0' ) { // get ...
How do I show child categories if in a parent category, and posts if in a child?
wordpress
The sidebar isn't appearing on my site: http://richardclunan.com/ I have a Text widget in the sidebar, with some test text in it… In 'Edit Page', there's no 'no sidebar' option… What things might I need to do to get the sidebar to appear? (I might have it so nothing appears in the sidebar area at all – just have it act...
@Richard, To answer your questions in their order: 1) Yes, it means dynamic sidebar(s) are supported 2) You add the code to whichever page files / templates you want the sidebar to render in 3) The sidebar will render EXACTLY where you place the code 4) You do not have to create a child theme, up to you, more on child ...
Sidebar not appearing
wordpress
I was looking for a way to attach a custom meta box to the edit screen of a page at a specific template. I found and tried this here and from my actual point of view this can't work that way. Let me explain why I think so: To determine, whether I'm on a screen using a specific template I need reference the global $post...
As I've already wrote in question comments, at the very beginning of creating the new post or page first choose a template and save as draft. Meta box will appear after save if right template is used. <code> &lt;?php add_action( 'add_meta_boxes', 'my_add_meta_box' ); function my_add_meta_box() { // get template file na...
The $post variable – Did I get the grasp of how the Backend actions get parsed?
wordpress
I want to disable some of the Jetpack modules such as Stats in order to check if they make the web site slower or not. But I couldn't see an option to disable modules one by one. Of course, one can disable the Jetpack plugin as a whole. Is there a way to disable Stats module only?
If you press the <code> "Learn More" </code> button for each Jetpack Module, you will get a <code> "Deactivate" </code> button showing up to the right. There is also a fork call Jetpack Lite http://wordpress.org/extend/plugins/jetpack-lite/ A NOT official "lite" fork of Jetpack plugin containing only Stats and WP.me Sh...
How to disable Jetpack modules such as Stats?
wordpress
I have a problem with the numbering of my comments when they extend to more than one page. On the new page the numbering starts from again from 1. Also, on page 2 the pingbacks/trackbacks don't appear anymore. This is the code I'm using in <code> comments.php </code> : <code> &lt;?php if ( have_comments() ) : ?&gt; &lt...
To fix the numbering, you'll have to modify the first code to reset numbering via CSS. This way (untested, but you'll catch the idea ;) ). <code> &lt;?php if ( have_comments() ) : ?&gt; &lt;h3 class="com"&gt;&lt;span class="com-titlu"&gt;&lt;?php comments_number('Niciun comentariu', 'Un comentariu', '% comentarii' );?&...
Comments numbering on multiple pages
wordpress
How can I add an image watermark to only those images which are to be published in gallery using a function in <code> functions.php </code> ? Images can be in <code> .jpg </code> , <code> .png </code> , <code> .gif </code> format. I also found this snippet which serves the same but it watermarks all the uploaded images...
This is what I put into a <code> watermark.php </code> file : <code> &lt;?php // loads a png, jpeg or gif image from the given file name function imagecreatefromfile($image_path) { // retrieve the type of the provided image file list($width, $height, $image_type) = getimagesize($image_path); // select the appropriate i...
watermarking gallery items
wordpress
I'm working on a customized login form for WordPress. I noticed that it's pretty difficult to achieve what I wanted. Here's the HTML of the form: <code> &lt;form method="post" action="&lt;?php bloginfo('url') ?&gt;/wp-login.php"&gt; &lt;div class="loginbox_fields"&gt; &lt;div class="loginbox_field"&gt;&lt;input type="t...
To redirect back to your custom login form after login fails try this code: <code> // hook failed login add_action('wp_login_failed', 'my_front_end_login_fail'); function my_front_end_login_fail($username){ // Get the reffering page, where did the post submission come from? $referrer = add_query_arg('login', false, $_S...
Properly customizing login/register form
wordpress
I am now experiencing a wired problem with my wordpress installation. I was surprised when I saw post view counter of another post also increased including the the post on which I clicked to try and check the result. I also observed that it increments the post view of another post from the same user. For more informati...
I am answering this because nobody yet answered this and I think this could help others who are experiencing this kind of issue. As mentioned by s_ha_dum that the issue is related to FireFox's Prefetching mechanism. In order to resolve this I inserted the below line to function.php: <code> remove_action('wp_head', 'adj...
single.php fires more than once after clicking on any post to view with different post id each time
wordpress
I'm trying to create a custom column for my custom post type and I'm having no luck. Below is the code I'm using, I have a similar code that pulls the featured thumbnail and that works for all post types, but this column will only show up on the custom post type. Any help would be appreciated. <code> add_filter("manage...
You're missing a couple of things hook for registering custom column is <code> manage_edit-{$post_type}_columns </code> thus you have to use <code> manage_edit-Featured_columns </code> on line one (instead of yours manage_Featured_columns ). hook for getting custom column content is <code> manage_{$post_type}_posts_cus...
Trying to create a custom column for a custom post type
wordpress
I am working with custom post types in the bones theme from themble. There, I want to create a link list and therefor i've created a custom post type, called links. This custom post type has a custom taxonomy, called links_categories. Now I would like to display all links on one page, like this: Link Category 1 Post 1 ...
If you look at your <code> var_dump </code> , near the end, you will see the actual query being used. <code> SELECT wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (93) ) AND wp_posts.post_type IN ('po...
Loop through multiple custom taxonomy terms and display posts for a custom post type
wordpress
I am importing a large amount of content from Expression Engine , the content in the other Expression Engine is all grouped together. I have created all the custom post types and taxonomies to organize the content better. However, Once I import the content to WordPress, I need to move the content into the newly created...
The information about post type is stored in wp_posts table in DB in column post_type - either post, page, attachement and other post types you've defined. So i quess you can use some SQL query in your case. Or you can write some script using WP_Query for fetching posts from cerain category (for example), and wp_update...
Move content between custom post types
wordpress
I'll try to be brief.... I have a theme that only supports one navigation menu. At this point I'd like to add 2 or 3 more menus. I have successfully registered my menus in functions.php with register_nav_menus and I am able to switch the header.php code manually between my different menus. My problem... Since my theme ...
First off, some things you should know about nav menus: Menus are simply terms in a taxonomy called <code> nav_menu </code> . Menu items are a special post type In short: menus are just like nearly every other piece of content in WordPress, they just have a custom UI. With that out of the way, the task is fairly simple...
How to change theme header to support multiple nav menus?
wordpress
The insertion of <code> ?doing_wp_cron </code> in Wordpress’s URL is very well documented stackexchange-url ("here"). My problem is a little different. I turned on the <code> ALTERNATE_WP_CRON </code> feature in my <code> wp-config </code> file a few days ago. Then, noticing this issue –i.e. the introduction of <code> ...
I have confirmed with my host that this is a normal occurrence in access logs when running WordPress crons. Also, since I disabled <code> ALTERNATE_WP_CRON </code> I didn’t come across any actual (live) URLs with the <code> ?doing_wp_cron </code> attached to them.
”doing_wp_cron” in URL even if ALTERNATE CRON is not in wp-config
wordpress
I've got table in the WordPress database that has lat &amp; lng stored and I'd like to add a sort feature on the results page 'Sort by Distance' that gets the locations that are closer to your provided lat &amp; lng. I'm using WP_Query, it needs to work with it. Thanks :) <code> $my_query = new WP_Query( array( 'post_s...
You want to use the Haversine formula http://en.wikipedia.org/wiki/Haversine_formula This plugin might be of interest to you: http://wordpress.org/extend/plugins/wp-geoposts/ Provides WP_GeoQuery an extended WP_Query class for doing distance based and geo-aware queries. it uses the Haversine formula here: http://plugin...
WP_Query posts by distance based on LAT & LNG in Database
wordpress
So far this code works if I run it as a page in WordPress. I am trying to send my user email updates when I publish a post with with a specific tag. The users can choose if they want to receive the updates in their settings page. Every time a post is published it checks if the post has the specific tag. Only one tag wi...
The post's data is passed as an argument to the function hooked to <code> transition_post_status </code> , so you don't need to query for anything (also, your query is a bit strange, using both WP_Query and query_posts, but that's a separate matter). Here's a trimmed version of your function showing the important chang...
how to run loop in function.php that sends email based on specific conditions?
wordpress
I know that we can get the parent category in normal post type by: <code> get_category_parents($cat, TRUE, ' &amp;raquo; '); </code> But how can we get the parent category in custom post type? I use this for: <code> if ( is_category() || is_single() &amp;&amp; !is_singular( 'portfolio' ) ) { // Full path links $categor...
Here is a modified version I made from the function <code> get_category_parents() </code> to support general taxonomies. <code> /** * Retrieve category parents with separator for general taxonomies. * Modified version of get_category_parents() * * @param int $id Category ID. * @param string $taxonomy Optional, default ...
get_category_parents for custom post type taxonomy
wordpress
I modified the woocommerce_custom_order_columns function to make some changes to the WooCommerce Admin Order page. Everything works great, except that Order Status shows up twice (but only for the latest (top) order). I've attached an image and the code that could be causing this. I have no idea what would make this ha...
Solved it. I used the plugins_loaded hook, like this: <code> add_action('plugins_loaded','example_function'); function example_function(){ remove_action('manage_shop_order_posts_custom_column', 'woocommerce_custom_order_columns', 2); add_action('manage_shop_order_posts_custom_column', 'match_order_woocommerce_custom_or...
WooCommerce Order Status Displays Twice on Order Page
wordpress
I've setup a few custom widgets for my theme, and when I go into Appearance > Editor, the widget file names are showing up in the list of files that can be edited. How can I prevent these widget file names from showing up in the Editor's list of files? I put them in a subdirectory ("widgets"), but they are still showin...
The editor won't traverse more than one directory deep, so a simple way to hide them is to put them in a dir within a dir: <code> /inc/widgets/my-widget-file.php </code>
prevent custom widget file names from showing in Appearance > Editor
wordpress
I want to bulk add a custom field (category) with value (photography) to all posts in a specific category (photography, with Category ID 5). I have used the code below to bulk add a custom field to all posts, but how can I narrow this down to a specific category? Anyone? This is the code I used for all posts: <code> IN...
You can use WordPress functions to do this and just run it once, a fast example would be. <code> function wpse_85236_add_photo_field(){ global $post; $photoquery = new WP_Query('posts_per_page=-1'); while ( $photoquery-&gt;have_posts() ) : $photoquery-&gt;the_post(); if ( in_category( 'photography' )) { add_post_meta($...
Add custom field to all posts in specific category
wordpress
I am trying to use pre_get_posts to exclude categories from posting to the homepage. If I do it like so it works just fine <code> $query-&gt;set( 'cat', '-13,-7,-19,-12,-24,-21,-14'); </code> that is hard coded in. I am building a custom admin that lists the categories in the admin menu. So now I want to use the id's t...
try to implode $category with "," as a glue. Mentioned code in each foreach run rewtites the cat variable of $query. <code> $query-&gt;set('cat', implode(',', $category)); </code>
using pre_get_posts to exclude
wordpress
I want to append the URL when viewing a single post. For example when im on a post I want the url to be something like: <code> example.com/mypage/mypage/single-post-article </code> The default url is <code> example.com/single-post-article </code> I did not find something here on WPSE or the goooglz, but I have read abo...
Go to your Settings > Permalinks page and set your permalinks to: <code> /mypage/mypage/%postname%/ </code> If you don't want categories to append <code> /mypage/mypage </code> , you can change their permastruct: <code> function wpa85084_category_permastruct(){ global $wp_rewrite; $wp_rewrite-&gt;extra_permastructs['ca...
Rewrite the base-url for single posts
wordpress
I'm having trouble adding sub nav menu items to my parent menu item under Buddy Press. The parent menu item as shown below, named <code> TEST </code> , shows correctly, but the tabs named <code> SUB NAV </code> and <code> SUB NAV 2 </code> don’t show at all. <code> function my_setup_nav() { global $bp; $em_link = $bp-&...
Asked and Answered here: http://buddypress.org/support/topic/create-sub-nav-menu-item-in-profile/ Did you try the suggested solution ?
Add Sub Nav Menu Item to Buddy Press Menu
wordpress
I have a client site that uses seo friendly URL's (/postname/) Up until yesterday they were using the default permalink structure of ?p=1234 They've had it set like that for years and have had their posts shared on facebook, twitter, and other networks. The problem with changing the permalinks now is that the social me...
Use one of the_shortlink (complete link) or wp_get_shortlink() (bare link) both introduced in WordPress 3.0.0.
Retrieve default permalink while using seo friendly URLs in WordPress
wordpress
I've just upgraded to WordPress 3.5.1 and the new <code> object-cache.php </code> version 2.0.2 that users some new switch to blog cache functionality. We had this issue with the previous version of object cache, but i managed to solve it by delete the users keys when doing signup and activation of the blogs. This clea...
This is now solved The solution was this in the activation script: <code> $blog_real_id = $wpdb-&gt;get_var("select blog_id from wp_bp_user_blogs where user_id = ".$user_id." limit 1"); wp_cache_key_delete("1:users:".$user_id); wp_cache_key_delete($blog_real_id.":users:".$user_id); </code> This clears the cached user i...
User cannot authenticate after signup when object cache enabled
wordpress
Functions Php : <code> add_shortcode( 'membervip', 'memberviparea' ); function memberviparea( $atts, $content = null ) { if( is_user_logged_in() ) return '&lt;p&gt;' . $content . '&lt;/p&gt;'; else return; } </code> Post : [membervip]Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismo...
Check if the user has left a comment <code> // the user may have commented on *any* post define( 'CHECK_GLOBAL_FOR_COMMENTS', TRUE ); // // some more code // function memberviparea( $atts, $content = null ) { $post_id = 0; // if the user have to left a comment explicit on this post, get the post ID if( defined( 'CHECK_...
Show content only if member left a comment
wordpress
If I look at <code> /wp-admin/users.php </code> I see all the users, but some have given a bogus email and never used their password. Is there some way to see who has used their password at least once? If not, is there a plugin to do this going forward?
If you install the following plugin and leave that one running for a while... you can see who logged in since using that plugin: http://wordpress.org/extend/plugins/wp-last-login/ That seems to do what you need. As far as I quickly can see it runs on $this-> hook( 'wp_login' ) and does: <code> $user = get_user_by( 'log...
Separate Out Real Users
wordpress
Due to the way my projects menu is coded/styled I'm having some difficulty figuring this out. I have appended a div to my menu using jQuery, and I want to be able to include an external php file that simply contains a wp_list_categories(); function wrapped in an unordered list. What would be the best way to go about do...
Use <code> wp_localize_script </code> to pass PHP data to Javascript. Store the result in a variable by setting the <code> echo </code> parameter of <code> wp_list_categories() </code> to <code> false </code> , and then pass the variable in the object you send to javascript through <code> wp_localize_script </code> . O...
Adding wp_list_categories to a specific div that was appended using jQuery
wordpress
I've had this issue several times now. While building a site, including some content, I keep wordpress in a subdirectory (say, <code> /wordpress/ </code> ). When putting it live, I move/copy 3 files out of the dir into the root, in accordance with the WordPress specifications here http://codex.wordpress.org/Giving_Word...
You're not doing anything wrong. WordPress does not monitor the links within content, so it's up to you to change them when your structure changes.
subdirectory install breaking existing links
wordpress
I have a serialized array as a meta value and I'm trying to run WP Query where it finds a specific value in the serialized array. Here's an example of the serialized array field: <code> a:6:{i:0;s:3:"173";i:1;s:3:"172";i:2;s:3:"171";i:3... </code> Here's my query, but it doesn't work: The ID's are numberic I'm doing a ...
I came across this same issue today. In both our situations, there is in fact a nice solution. Because the serialized data we are searching for, are simply IDs, and they are always wrapped in quotations, we just need to include the quotations as part of the query. This eliminates the problem of encountering false posit...
LIKE %...% Meta Query
wordpress
Every time im about to put my local project into staging/production environment im beeing hardly reminded that WordPress saves all the urls as absolute.So i need to rewrite all the urls with a SQL-query, or use something like Search-and-replace script . But why is WordPress doing this? What is the benefits? Is it a mus...
If there were only relative URLs, what would they be relative to? A post can be viewed in several different contexts, including a feed, and a WordPress install can move into a different directory relative to root. There are issues with doing it either way, absolute URLs just give you a more concrete starting point from...
Why is WordPress saving full-urls to the database?
wordpress
I am trying to make a shortcode that will create a dynamic dropdown list of downloadable file links, that once selected, html will show a download link below the dropdown. Here is the end result of how the shortcode will function: http://jsfiddle.net/KKyE9/ I am struggling with how to turn the shortcode array into a mu...
Based on your example at the bottom of your question, and your statement that you would like something like that for readability, I'd do something like this: <code> function dropdown_option($atts) { $dropid = (isset($atts['dropid'])) ? $atts['dropid'] : ''; global $sco_array; if (!empty($atts['value']) &amp;&amp; !empt...
shortcode to create dynamic dropdown box form shortcode attributes
wordpress
I like to learn some of WP automation. The WP get inbound http request to site url and the question is how to create a publication based on post (or get) data structure? How can maintain eventhandler for this and take string from the array of $_POST? to make all of this <code> wp_insert_post( array( 'post_title' =&gt; ...
As a general note, there's the http-api (you've already used it to tag your question) that has an archive. WP HTTP API Here's a list of "How to"-answers about the HTTP API basics stackexchange-url ("chose the right protocol") stackexchange-url ("filter the request uri/url"). stackexchange-url ("download a file") from a...
Is it possible to process $_POST / inbound http request in way to automatically create Wordpress post?
wordpress
My question is partly based on this answer: stackexchange-url ("stackexchange-url Mike's answer is really great, and the solution worked fine until I needed to include my meta box in a custom post type. I tried to alter the code until that worked, but I did not succeed. I also do not need more than one selection meta b...
I believe this is what you were looking for. I moved back to using a class because what you were using would very easily conflict with someone else's code who decided to use the function names <code> select_box_add_meta_box() </code> , <code> select_box_content() </code> and/or <code> select_box_save_postdata() </code>...
Populating meta box with select-list of existing posts, and assigning it to custom post types
wordpress
I'm trying to implement a jQuery accordion for a client of ours. Basically, it's this tutorial ( http://wp.tutsplus.com/tutorials/creative-coding/create-an-faq-accordion-for-wordpress-with-jquery-ui/ ) but having problems enqueuing the jQuery. Basically, this is the code that is trying to enqueue the accordion script f...
The 3rd parameter in the call to <code> wp_register_script() </code> should be an array of dependencies - not a string. Change this: <code> wp_register_script('fl-custom-js', get_template_directory_uri() . '/faq/faq.js', 'jquery-ui-accordion', '', true); </code> To: <code> wp_register_script('fl-custom-js', get_templat...
jQuery.accordion isn't a function even when enqueued
wordpress
I want to set a special styling for the ul tags created by Tinymce only, which means only for posts and pages, I only found this filter tiny_mce_before_init with an example on how to add custom style options to an existing style dropdown. so is there a way to add a class to ul tags created by the WordPress editor ?
It's always a good idea to look at Wordpress Codex before asking. TinyMCE Custom Styles <code> &lt;?php // Insert 'styleselect' into the $buttons array function my_mce_buttons_2( $buttons ) { array_unshift( $buttons, 'styleselect' ); return $buttons; } // Use 'mce_buttons' for button row #1, mce_buttons_3' for button r...
How to add a class to ul tags created by the WordPress editor Tinymce?
wordpress
I need public users to be able to submit posts, then have them be approved by a moderator or admin on the dashboard. Is this possible to do? I would like it to function very similarly to comments. for example, users will post their own stories and then a moderator will approve it being posted. I am new to this particul...
If you don't want to give users access to the WordPress admin screens and you don't want to use a premium plugin, you should create a form in a page and use wp_insert_post with the submitted data. In your case, the "post_status" parameter could be used to "moderate": <code> $post = array( 'post_title' =&gt; $_POST['tit...
Allow public to post on blog
wordpress
When an image is added to a gallery, the resulting attachment URL is generally displayed in a structure like this: example.com/post-slug/attachment-slug/ However, take a look at my gallery: http://themeforward.com/demo2/?p=2195 and view an image. What could be preventing this slug from appearing correctly? The images h...
you have to edit your settings > permalinks
WordPress Gallery Permalink Structure Displaying Incorrectly
wordpress
I can't seem to get archive page or category page to work correctly. I am following http://codex.wordpress.org/Template_Hierarchy#Category_display and it still defaults to archive.php ( i think, according to chart ) even though I have named it category-business.php here is my code: <code> /****************** // Busines...
Since you are using a custom taxonomy and not the native post categories you need to name your file <code> taxonomy-{taxonomy}.php </code> and in your case it would be <code> taxonomy-mycategories.php </code> Take a look at the section of the template hierarchy to display custom taxonomy archives .
custom post type category page
wordpress
All my enqueued styles are applied to the back-end as well. I have never encountered this behavior before. Here's my code: <code> wp_register_style( 'main-styles', get_stylesheet_directory_uri() . '/css/styles.css', false, '1.0.0', 'all'); wp_enqueue_style('main-styles'); </code>
Why are my styles being applied to the admin area? Assuming that is all of the code, it is because you are enqueueing the styles globally. You need to hook that to <code> wp_enqueue_scripts </code> , which will only load on the front end. <code> wp_register_style( 'main-styles', get_stylesheet_directory_uri() . '/css/s...
Why are my styles being applied to the admin area?
wordpress
With the advent of responsive design, it's beginning to simply make sense that we could make a site into an app. The concept is simple: When the user is on the site, remove the browser around the site so that it appears to be like any other app Provide the appropriately-sized icons for devices (tablets, smartphones, et...
The best way to do this would be to use CSS3 media quires: <code> @media (max-device-width: 480px) </code> but requires more work. The quick and dirty way to make your WordPress theme app-like would be to add the viewport meta tag to the <code> &lt;head&gt; </code> of your page: <code> &lt;meta name="viewport" content=...
Turning a WP Site Into an iPhone/iPad App
wordpress
The array below with "'taxonomy' => 'age'" isn't working, if I copy and paste the array "array( '19', '20' )" in place of the variable it works fine. I just started picking up PHP so go easy on me :) <code> if($_REQUEST["price"] == 19){$price = "'19'";} elseif($_REQUEST["price"] == 20){$price = "array( '19', '20' )";} ...
Your array definitions aren't correct. This... <code> elseif($_REQUEST["price"] == 20){$price = "array( '19', '20' )";} </code> ... creates a literal string that reads "array( '19', '20' )". Remove the quotes. <code> elseif($_REQUEST["price"] == 20){$price = array( '19', '20' );} </code> That should give you PHP arrays...
WP_Query Variable inside Array
wordpress
I've created a child theme basing on twenty twelve. Since I present the content a little bit different on home and on the archive page, I'd like to know inside <code> content-[format].php </code> on which page the post is being rendered. Then, I can decide which image size I can present. How can I know it?
You can use the global <code> $template </code> . The following function returns the <code> basename </code> of the template file being used: <code> index </code> , <code> archive </code> , etc. <code> function get_template_name_wpse_85011() { global $template; $filename = basename( $template, '.php' ); return $filenam...
How to recognise on which site the content is being rendered?
wordpress
I am working on a Wordpress theme that has a homepage slider. I have a table in Wordpress database that stores post view counts and I would like to make my slider show the top viewed posts. This is the SQL to get the top post, Post ID's <code> SELECT `post_id`, `single_views` FROM `wp_ak_popularity` ORDER BY `single_vi...
if I understand you correctly, you might want something like this: <code> global $wpdb; $number=30; // EDIT this to your needs $sql="SELECT post_id FROM `wp_ak_popularity` ORDER BY `single_views` DESC LIMIT %d"; $my_top_posts = $wpdb-&gt;get_results($wpdb-&gt;prepare($sql,$number),ARRAY_N); </code> to get an array of t...
Make a database query using WordPress
wordpress
I have a options page and i use this code. I want this, I add author id on sometext field (e.g 3,2,5,11 ) and my author.php redirect custom author page. My author.php <code> &lt;?php $post = $wp_query-&gt;post; $options = get_option('sample_theme_options'); if (is_author( array($options['sometext']) ) ) { include(TEMPL...
You can do the following: <code> &lt;?php $post = $wp_query-&gt;post; $options = get_option( 'sample_theme_options' ); $authors = explode( ',', $options['sometext'] ); if ( is_author( $authors ) ) { include ( TEMPLATEPATH . '/brand.php' ); } else { include ( TEMPLATEPATH . '/customauthor.php' ); } ?&gt; </code> This wa...
how can authors to define custom pages?
wordpress
I am hoping that someone can shed light on this problem I am trying to solve, even if simply changing my thought process as to how I could solve this. I am importing a custom CakePHP based CMS web application into WordPress by means of traversing the database, making numerous SQL queries, building arrays and finally ou...
Yes you can by programatically adding the attachment. <code> $upl = wp_upload_dir(); $target = $upl['basedir'] . '/YOUR_CUSTOM_FOLDERS/YOUR_FILE'; $filetype = wp_check_filetype($target); $attachment = array( 'post_mime_type' =&gt; $filetype['type'], 'post_title' =&gt; $YOUR_FILE_TITLE, 'post_content' =&gt; '', 'post_st...
Importing WordPress Attachments Into Custom Directories In wp-content/uploads/
wordpress
For some reason I'm finding it a struggle to grab any posts using a custom taxonomy... can anyone unravel my stupidity? <code> $args = array( 'post_type' =&gt; 'adverts', 'advert_tag' =&gt; 'politics' // Doesn't seem to work. ); query_posts($args); while ( have_posts() ) : the_post(); //Show Posts endwhile; </code> Tax...
Firs of all don't use <code> query_posts() </code> ever , read more about it here: stackexchange-url ("When should you use WP_Query vs query_posts() vs get_posts()?"). You have to use <code> WP_Query </code> to fetch posts what you need. Read documentation for it. In your case the query could be like this: <code> $the_...
How do I query a custom post type with a custom taxonomy?
wordpress
I use Wp 3.4.2 and Featured Image. After I feel the Title, Alternate Text and publish the post, html code looks like this: <code> &lt;img width="214" height="300" title="" alt="Test" class="frame wp-post-image" src="http://www.website.com/wp-content/uploads/2013/02/Test-214x300.jpg"&gt; </code> Is there a way to fix th...
you can try this filter <code> add_filter('wp_get_attachment_image_attributes', 'my_img_title', 10, 2); function my_img_title($attr, $attachment = null){ $attr['title'] = get_post($attachment-&gt;ID)-&gt;post_title; return $attr; } </code> It should give the the extra title attribute in the img tag. You can also use th...
Title image is missing ( but is not the WP 3.5 issue )
wordpress
Trying my hand at pulling some info from Google API, and having a bit of trouble. My code: <code> $body = array( 'intitle' =&gt; 'Test', //Returns results where the text following this keyword is found in the title. 'inauthor' =&gt; '', //Returns results where the text following this keyword is found in the author. 'in...
I'm pretty sure you have to add the keywords or the search terms directly to the query, for example: <code> $key = 'flowers'; // search for word flowers in book titles. // fill rest in as you desire $args = array( 'timeout' =&gt; '5', 'redirection' =&gt; '5', 'sslverify' =&gt; false // for localhost ); //check for titl...
wp_remote_get with Google Books API
wordpress
I'm trying to display the first and last name of an author without having to change the "Display publicly as..." setting. Problem is, I can only seem to find solutions for either or, or at best display/nice/nickname. I would like to display the full name no matter what the user/author has chosen to "Display publicly as...
Try the following: <code> &lt;?php $fname = get_the_author_meta('first_name'); $lname = get_the_author_meta('last_name'); $full_name = ''; if( empty($fname)){ $full_name = $lname; } elseif( empty( $lname )){ $full_name = $fname; } else { //both first name and last name are present $full_name = "{$fname} {$lname}"; } ec...
Get author full name
wordpress
I am trying to get WP is using Mod_Write or $_GET for URLs, Because by it, I can generate my own links like: <code> mysite.com/val1/val2 </code> or in a conventional way; <code> mysite.com/?var1=val1&amp;var2=val2 </code> $_GET or rewrite, how to detect that which way WP is currently using?
You can check for the <code> permalink_structure </code> option value. If this value is an empty string, WP is using the default permalink structure ( <code> /?var1=val1&amp;var2=val2 </code> ), otherwise WP will be using the pretty permalink structure ( <code> /val1/val2 </code> ): <code> if ('' != get_option('permali...
How to Detect That WP is Using Mod Rewrite or $_GET variables?
wordpress
I am having trouble of getting the ID in user_register filter in functions.php... Here is what I got <code> add_action( 'user_register', 'sendanotheremail' ); function sendanotheremail($user_id) { $user = new WP_User($user_id); $user_login = stripslashes($user-&gt;user_login); $user_email = stripslashes($user-&gt;user_...
You are giving <code> $wpdb-&gt;get_results </code> a string for its second parameter. It should be a constant-- <code> ARRAY_N </code> -- meaning you need to remove the quotes <code> $getunion = $wpdb-&gt;get_results( "SELECT value from wp_bp_xprofile_data where user_id = $getid AND field_id = 4", ARRAY_N ); </code> S...
get USER ID in functions.php using user_register action
wordpress
I'm developing a mobile site and the template I'm using is based off of Jquery Mobile. In the header.php file, the template I am using is making calls to CDN javascript files: <code> &lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile- 1.2.0.min.css" /&gt; &lt;script src="http://code.jquer...
Technically yes, you can add those lines to your header.php file just after the wp_head() function and it'll load the jQuery from a remote source, just like it was on your local machine. If you want to do it properly, take a look at http://codex.wordpress.org/Function_Reference/wp_enqueue_script which will allow you to...
How to add additional JavaScript code
wordpress
I just found out that editors are not allows to post iframes (e.g. YouTube videos). Is it possible to allow it somehow? I use WP Multisite.
try the iframe shortcode plugin http://wordpress.org/extend/plugins/iframe/ Embed iframe using shortcode [iframe src="http://player.vimeo.com/video/819138" width="100%" height="480"] ps: you can also use the default oembed shortcode: <code> [embed width="123" height="456"]...[/embed] </code> it supports YouTube, Vimeo,...
Allow editors to post iframes
wordpress
0 down vote favorite I show my last post in a page with this code: <code> $query1 = new WP_Query(); $query1-&gt;the_post(); </code> and it further with: <code> $id = $query-&gt;ID; </code> to retrieve last post ID so I wrote a new wp_query and I want to exclue that ID from the results: I wrote this but it don't work: <...
If I'm understanding your specific question (and posted code) correctly, you're actually trying to exclude the most recent post from your query? If so, there's a much easier method: use the <code> offset </code> parameter : <code> $query2 = new WP_Query( array( 'offset' =&gt; 1 ) ); </code> Using this method, you exclu...
exclude a post from wp_query loop
wordpress
Im having a weird problem. The screen where you manage widgets (drag and drop them from left to right) suddenly disappeared. How can I access it? It should be accessible via admin> themes> widgets but I dont have that option in the sub menu. Only have "themes" "menus" "editor" Btw, Im using ithemes theme builder plugin...
This is both a change in WordPress core in 3.5, and a problem specific to your commercial Theme. In WordPress 3.5, if a Theme does not register support for dynamic sidebars (i.e. Widgets), then the WP-Admin does not display the <code> Appearance -&gt; Widgets </code> admin page . So, if the behavior changed between Wor...
wordpress widgets screen disappeared
wordpress
Context: I use framework parent themes (e.g. Thematic) mainly because it ensures that my custom themes inherit cutting-edge and standard compliant code. Why I'm not yet using starter themes: I'm reluctant to use starter themes (e.g. _s, Bones etc.) because, as I understand it, I'll need to screen for code changes with ...
You can enable child themes for any theme: http://codex.wordpress.org/Child_Themes If you want your parent theme based off another parent theme, for example you want a theme based off of Twitter bootstrap and apply any changes they make to your framework, without over-riding your changes, use revision control. Git Merc...
Updating parent themes vs. updating starter theme
wordpress
WordPress user profile page uses the administration interface, and its user registration / login page is not part of the theme. I would like to change it into the custom theme of my site customize login / registration page, hopefully with a custom form, and captcha remove the top bar when the user is logged on retain t...
This certainly can be done, but it requires some work. I am developing a pretty complex plugin for a client, and I plan to expand on it and make it available publicly when it is ready. Telling you everything would take ages, so I will just give you some pointers on how you can achieve what you are aiming for. Make a pa...
Custom user profile, registration, login page with theme
wordpress
is there a nice function I can use to limit logged in users to one comment per post? I'm setting up a review system and only one review permitted per user. Thanks.
<code> &lt;?php global $current_user; $args = array( 'user_id' =&gt; $current_user-&gt;ID, 'post_id' = 100, // post ID. Can be '$post-&gt;ID' depending where you are calling this from 'count' =&gt; true ); if(get_comments($args) &gt;= 1){ echo 'disabled'; } else { comment_form(); } </code> Function_Reference/get_commen...
Limit user to one comment
wordpress
I would like to display the full list of categories on the Page creation page, so that the user can pick using checkboxes which category posts should appear on that page. I then need to retrieve the chosen categories for that specific page in my custom page templates, so that I can modify my loop to filter for only tho...
By default page post type doesn't support category taxonomy. But you can easily fix it by register category taxonomy for page post type: <code> add_action( 'init', 'wpse8170_init' ); function wpse8170_init() { register_taxonomy_for_object_type( 'category', 'page' ); } </code> Now you will see categories meta box in the...
How to insert category list into post creation page, and retrieve chosen categories?
wordpress
I have a Custom Post Type named " Cars " and 2 Custom Taxonomies " Ferrari " and " Lamborghini ". Each taxonomy has 2 Terms : " New " and " Used ". These URIs work as expected: <code> http://myhost/ferrari/new http://myhost/ferrari/used </code> The problem is, of course, when I append the car ID at the end I get a 404 ...
You can try this: <code> function my_car_rewrite_rules( $rules ) { $newrules = array(); // add a rule for this kind of url: // http://myhost.com/cars/ferrari/used/123 // =&gt; http://myhost.com/index.php?post_type=cars&amp;ferrari=used&amp;p=123 $newrules['^cars/([^/]+)/([^/]+)/([^/]+)$'] = 'index.php?post_type=cars&am...
Append custom parameter to taxonomy/term URI
wordpress
I'm currently using this plugin http://wordpress.org/extend/plugins/automatic-featured-image-posts/ which creates batches of posts from uploaded images I'm also using this code here to generate the default content for every new post <code> add_filter( 'afip_new_post_content', 'diww_default_post_content' ); function diw...
Everytime you upload a new image, the <code> afip_new_post_content </code> filter is called which can be used to change the post content before creation - http://wordpress.org/extend/plugins/automatic-featured-image-posts/ Assuming you have a list of URLs stored somewhere - like in the database - you need a function th...
Insert dynamic content into posts
wordpress