Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

UCFkid86 on "Multiple custom post types created from one Gravity Form."

$
0
0

Hello,

I'm attempting to create a Gravity Form which will create a post of two post types,
teardownand engine.

I am successful in creating the actual posts from the form submission, however, none of the custom field data is being written to the database. I'm left with empty post, albeit correctly created by the form, but no form data. It seems to be a disconnect with $entry[] in the meta arrays. I'm receiving emails of form submission confirmations with field data, but nothing is populating in the posts when I view in Admin.

Here's my code below:

add_action( 'gform_after_submission_1', 'after_submission', 10, 2 );
function after_submission() {
    // TEARDOWN POST TYPE STARTS HERE
        $td_post_args = array(
        'comment_status' => 'closed',
        'ping_status' => 'closed',
        'post_author' => $user_ID,
        'post_title' => $entry[1],
        'post_status' => 'draft',
        'post_type' => 'teardown',
    );
    $post_id = wp_insert_post( $td_post_args );

    // TEARDOWN CPT META VALUES
    $td_meta_values = array(
        'wpcf-td-mfg' => $entry[2],
        'wpcf-td-model' => $entry[3],
        'wpcf-td-msn' => $entry[4],
        'wpcf-td-location' => $entry[7],
        'wpcf-td-tail-number' => $entry[5],
        'wpcf-td-last-operator' => $entry[6],
    );
    if ( $post_id > 0 ) {
        foreach ( $td_meta_values as $key => $value ) {
            update_post_meta( $post_id, $key, $value );
        }
    }

    // ENGINE POST TYPE STARTS HERE
    $engine_post_args = array(
        'comment_status' => 'closed',
        'ping_status' => 'closed',
        'post_author' => $user_ID,
        'post_title' => $entry[1],
        'post_status' => 'draft',
        'post_type' => 'engine',
    );
    $post_id = wp_insert_post( $engine_post_args );
    $engine_meta_values = array(
        'wpcf-td-engine-model' => $entry[11],
        'wpcf-td-engine-pn' => $entry[13],
        'wpcf-td-engine-qty' => $entry[14],
    );
    if ( $post_id > 0 ) {
        foreach ( $engine_meta_values as $key => $value ) {
            update_post_meta( $post_id, $key, $value );
        }
    }
}

I'm also confused with this portion, as this check should be returning an integer if the creation of the posts is successful (which it has been).

if ( $post_id > 0 ) {
        foreach ( $td_meta_values as $key => $value ) {
            update_post_meta( $post_id, $key, $value );
        }

Why are the custom fields not being populated by the form data?


arlinaite on "whitelist CloudFlare's IP addresses"

$
0
0

May be some body cold help. I'm using w3 Total cache and I few hours ago change my DNS to Cloudflare
I have to whitelist CloudFlare's IP addresses I find in cloudeflare
You would put these commands in .htaccess to whitelist CloudFlare's IP addresses:
https://support.cloudflare.com/hc/en-us/articles/200169296-How-do-I-whitelist-CloudFlare-s-IPs-in-htaccess-
Server support told me, that may better don't put the rule for ipv6 to avoid versions conflict. (I don't understand what that means)
I think that the rule must be something like this, but not shore.

# BEGIN(IPv4)
Order Deny,Allow
Deny from all
Allow from 199.27.128.0/21
Allow from 173.245.48.0/20
Allow from 103.21.244.0/22
Allow from 103.22.200.0/22
Allow from 103.31.4.0/22
Allow from 141.101.64.0/18
Allow from 108.162.192.0/18
Allow from 190.93.240.0/20
Allow from 188.114.96.0/20
Allow from 197.234.240.0/22
Allow from 198.41.128.0/17
Allow from 162.158.0.0/15
Allow from 104.16.0.0/12
Allow from 172.64.0.0/13

Thanks in advance

starflamedia on "How to use relative paths that would work after launch?"

$
0
0

Hi All!

I am a big fan of relative paths and no matter what anyone says I will go on looking for cleaner, shorter code no matter what.

When I build a WP site in development environment including local server on my computer or a beta folder under my future domain name, I use images in my posts by ftp upload in a folder called /images/ in the root directory of wordpress. This is so I do not type /wp-content/images, or anything else. It's just what i have assumed as the shortest code I can write like /images/image1.jpg.

How can i and why doesn't WP recognize a path as follows "/images.filename.jpg" when the WP files are in a subfolder such as /beta/ or /test/? It keeps lookig for the images in the root directory of the path even when i have specified the WP folder is either /beta/ or /test/? None of my images would show unless I specify that temporary "beta" or "test" folder!

My workaround has been to add an /images/ and /img/ folders in the root directory of the server during development that I then copy to the specific WP folder right before launch.

None the less, it's been bugging me and it makes it difficult to work on several sites at the same time, since they would share those /images/ and /img/ folders.

Is there any way I can have either an htaccess redirect or WP setting where it would rewrite EVERY RELATIVE PATH WITHIN WP to the correct NEW path? I tried every suggestion for the htaccess that i could find and none have worked so far.

There's no way I will ever consider using the native media importer in WP - the sites I build often have thousands of products with multiple images each. I like to be organized.

The bottom line is - I want to upload my images with FTP and stick to a relative path!

Thank you!

kiannachauntis on "Modifying Wordpress Search to Pull From Tags"

$
0
0

Alright, so I know this has been asked *several* times before, and I hate to be the one to ask again, but my situation is a bit different from what I've seen from other posts. However, I can't seem to find a straight answer.

Myself and another programmer have helped to create this website -
http://www.newamericangoods.com/

(Pardon the kinks, it's a work in progress)

We have managed to create a collective of brands that make their products in the US using custom post types. We also built a custom search system that filters these things based off of taxonomies for category, location, quality of the products and so on.

The person we are building this for has put a lot of time into tagging all of these products in hopes that this would help people be able to find them via the search bar, after of course filtering out the things they need from our dropdowns.

However- low and behold- the search box is only pulling from titles and content. We absolutely need this to pull from titles and tags only.

Every post I have seen has been telling people to use the "Search Everything" plugin. I tried that as well as the WP Extended Search plugin and neither seem to work. I assumed at first that this is because we aren't grabbing the default wordpress search form, but rather using our own. However, when using the default search on our "nothing found" page, it still rendered no results.

Does anyone have any links/references/know-how on how to just edit Wordpress core search to pull from tags and titles like this? I am relatively new to search queries myself, but my other programmer is a bit more seasoned but having the same issues finding answers that I am.

Any help or pointers will be greatly appreciated!

LavishDhand on "Code for edito's eccess broke something"

$
0
0

Hi!

I wanted to grant editors the access to edit menu. Found the following code while seraching for a solution and used for a test. Now I have removed the code from my functions.php file however the affects are not reverting back to normal.

This code is no more in use but editors still have access to the appearance menu.

Kindly help

// get the the role object
$role_object = get_role('editor');

// add $cap capability to this role object
$role_object->add_cap( 'edit_theme_options' );

tinfoiler on "More tag links to seperate domain"

$
0
0

Hi,

Im trying to customise the <!--more--> tag to link to a seperate domain.

The site currently runs on domain1.com however when someone clicks 'Read More' i want it to link through to domain2.com.

I currently use the following code in functions to customise the wording of the more tag;

//custom read more.
add_filter( 'the_content_more_link', 'modify_read_more_link' );
function modify_read_more_link() {
return '<a class="more-link" href="' . get_permalink() . '"><i>Continue Reading</i></a>';
}

Can the above code be updated to link to a second domain? I do not have much php coding experience. If anyone could advise it would be appreciated!

geekjon on "How to exclude tags via URL parameters?"

$
0
0

I'm looking to add a feature to my site where the homepage and feeds could be customized via URL parameters to exclude posts with certain tags.

An example for someone who wants to see all posts except those tagged "dogs":
http://example.com/exclude/dogs/
or
http://example.com?exclude=dogs

Ideally, it would need to also accept multiple exclusions:
http://example.com/exclude/dogs,cats/

The same functionality should also work for feeds:
http://example.com/feed/exclude/dogs,cats/

Any tips on how to accomplish this would be appreciated.

gotorx7 on "How run code based on category?"

$
0
0

Hi All..

I have a site which has 4 basic post types, identified by Category.

Based on the category I display a different format (EG - Text, Images, Videos and Links (to other web-sites).

This works great, but I'd like to extend the functionality to the search page and individual post displays, which currently show in the default formats.

I've searched, but haven't able to come up with anything that helps me, so any thoughts would be appreciated please.

Cheers,
Dave


nerdland on "Bulk editing/removing inline images?"

$
0
0

I have a strange situation and I'm wondering if anyone has any tips...

I'm helping out with a blog that has been around for about 6 years, has about 4500 posts, and -- until recently -- had about 22,000 images in the media library. Unfortunately, another developer managed to wipe the entire site last week, and their backups were abysmal. I had a recent copy of the database and theme files on my local computer, but their uploads folder was 17GB, so I never copied that over from the server.

As a result, their image content is basically gone now. That sucks in general, but it also sucks because it leaves a ton of broken images in their posts.

I removed all of the old entries from the media library, so if anything was set as a featured image, that can fall back gracefully rather than just showing a broken image. But for anything that was inline, we're still left with a broken image.

Is there a way for me to go through and remove inline images in posts that are no longer in the media library? I'm kind of surprised WordPress isn't smarter about that. If images were inserted into posts as shortcodes rather than just inline <img> tags, it would be much easier to make sitewide adjustments to your inline images and to fall back gracefully in situations like this.

amrinsmith on "You should feel enthused and ready to go after a workout"

$
0
0

Action Fuel Pro You should feel enthused and ready to go after a workout, and not tired. Make sure you are including exercises in the cardio category like jogging, running and aerobics. You can also consider adding strength training for specific muscles groups depending on your energy level. Organize your fitness routine so that there is a sequence. Begin your workout with dumbbells first, barbells second, and use machines last. Strength coaches advise that the smaller muscles used with dumbbells experience fatigue before the larger muscle groups. Using machines increases the effectiveness of your workout by allowing the small muscles to rest as you continue to exercise your larger muscle groups.
Read More>>> http://www.supplementsdeal.com/action-fuel-pro/

dgcov on "wp_query omitting posts and returning duplicates."

$
0
0

I'm not sure what's going on here.

This is my code:

$events=new WP_Query( array('post_type'=>'team_list_event') );
  if($events->have_posts()){
    while($events->have_posts()){
      $QID=$events->post->ID;
      echo '
      <tr><td>
      <a href="">'.get_the_title($QID).'</a>
      </td></tr>';
      $events->the_post();
      $i=($i==0)?1:0;
    }
    echo '</table>';
  }

I have 2 posts, ID 6 and ID 22.

ID 6 is skipped and ID 22 is rendered twice.

I've obviously misunderstood how the loop works: what am I doing wrong?

I suppose I could set up a query "SELECT ID,post_type FROM wp_posts WHERE post_type= 'team_list_event'", but I want to do it the proper way.

dgcov on "'parse_request' action hook generates "Nothing Found" error message"

$
0
0

I want to instantiate a function based on a URL and I've used the method detailed in this blog:

add_action('parse_request', 'team_parse_request');

function team_parse_request($wp){
  if (array_key_exists('event', $wp->query_vars)){
    renderPost();
  }
}

This works.

I have a link on my page as follows:
http://threepwood/teamtest/index.php?event=22

If I click on the link, it takes the event ID and renders the required page correctly.

However, it generates an error message at the bottom of the page which says "Nothing Found".

donnersm on "Innerhtml text replacement"

$
0
0

CAn't get my template to work.
In het header.php i included the following script:
<script>
function showUser(str)) {
if (str == "") {
document.getElementById(naam).innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById(replaceMe).innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
}
</script>

In the template.php file i have this:
..
..
<div id="replaceMe" class="retourtxt" ><b>Kies hierboven de eerste inleiding van de les</b></div>
..

At some point in the template , I call the script ..te script will get some more data from a database and replaces the innertext from replaceMe

By testing i know that:
- the script routine is called when needed, the call to the getuser.php is also excecuted...it gives back the data..
for some reason i cant get the replaceing to work..
what is their with this innerhtml that i am missing.
FYI, if i code it into simple HTML as standalone, it works
( http://www.judoles.nl/lesformulier )perfectly..just not as a wp template..
What am i missing here?

alifaraz on "One of my wordpress file name changed or deleted automatically"

$
0
0

Hey Everyone,

I am facing a very unual problem form the last couple of weeks. One of my wordpress file name changed or deleted.
In detailed wp-include/link-template.php file name changed to wp-include/link-template.php.suspected or sometime this file is missing. And all the happening in a specific time spam on daily bases.

Please help out how can i over come to this.

Thanks

dgcov on "Newly created page appears in menu"

$
0
0

If I create a page it is automatically added to my menu.

global $user_ID;
  $page['post_type']    = 'page';
  $page['post_content'] = $content;
  $page['post_parent']  = 0;
  $page['post_author']  = $user_ID;
  $page['post_status']  = 'publish';
  $page['post_title']   = $title;
  $pageid = wp_insert_post ($page);

If I change 'post_status' to 'private', then it doesn't appear in the menu, but can't be read either. It also has the word "PRIVATE" added to the title.

I see there is an option to define custom status, but I'm unsure how to use it or whether it will help.

I want to create a page that isn't added to the menu, on which I can place my shortcode to call a function to render a page.

Calling the page from the menu isn't going to work because it needs additional parameters.


dawgawel on "wp.media.query multiple types"

$
0
0

Is it possible (and how) to create js media collection using multiple (but not all) media types, for example 'image' and 'video'?

For example:

if ( ! this.get('library') ) {
    this.set( 'library', wp.media.query( { type: 'image|video' } ) );
}

Neoraj3 on "making the email field Optional"

$
0
0

I went to comment.php in Appearance > Editor

then commented out these lines of php with /* */ I presume this is all as it works.

First instance::
<?php /* echo get_avatar($comment->comment_author_email, 82); */ ?>

Second Instance::
/* 'email' => '<p class="input-block">
<label for="comment_email" class="required">' . __("Email <span>(required):</span>", kopa_get_domain()) . '</label>
<input type="email" name="email" id="comment_email"
value="' . esc_attr($commenter['comment_author_email']) . '" >
</p>', */

ltdJ on "Sharing Unknown image on Facebook"

$
0
0

Hi guys,
I've been trying to fix the share image on my blog so that when it shares on Facebook people can see that it's a video and Facebook sees it as a video- Not only have I not figured that out, now I'm sharing the image a sleeping cat and I don't know where it came from. I never added it. Sometimes it also shares a picture that I had but deleted. I'm using and old theme- Luxury- I keep trying to find that image but can't figure it out. I added and ran WP Super Cache and that did not help.
Thanks for your help.

Hazno on "Overwriting post image attachment size"

$
0
0

I know the editors of a blog can change the size of image attachments within a post (typically small, medium, large and full size) when they add media. However, it's not always the case that all editors do this properly. This allows some posts to have images in full size (with resolutions in the thousands). Even though images are being scaled to fit the content through CSS, it's not in any way an optimal solution. I want a fool-proof solution for this.

I've tried googling this for some time now, and I can't seem to find a good solution. Ideally I'd prefer to filter all image attachments within a blog post and apply a custom image size to them (which I've prepared using "add_image_size") with no cropping. The custom image width is fixed, but the height is dynamic. I doesn't matter whether the images are in full size in the editor, I just don't want the full size images to be loaded for the visitors.

This is not the featured image of a blog post, but the images/media within the single blog post.

Any ideas, or if there's a filter I can apply to make this happen (or simply a plugin I can use) ?

Thanks in advance!

foodergolove on "Remove just the word "No" from no search results page."

Viewing all 8245 articles
Browse latest View live




Latest Images