How to attach images to current post being edited with acf custom field

I am using ACF, NOT the pro version, and I also have a plugin called ACF Photo Gallery Field that I am using to make user albums. I used CPT UI to make the custom post type “Albums” and added the gallery field with ACF. I am also using Elementor Pro to make my custom post template and ACF Frontend Form plugin to put the edit album/create album forms on the templates so users can create their own albums and add more images to them from the frontend. I use the Code Snippets plugin to add codes to my functions.php. I have also used the gallery widget through Elementor Pro and used the dynamic content to add post attachments to the gallery so the images will show up on my albums. Also, I have a “Create New Album” page with a form for making a new album. Everything for that works except the upload images field when I try to add images to the newly created album as it is being created. It all works if i do it from the backend, but not from the frontend. The problem I am having is that the images I have uploaded using my edit album form and the images added during the create new album process are not attaching to the current album/new album being edited/created. I have been searching for a solution for several weeks and nothing I have tried is working. I am very new at PHP and website development, but I know the basics of how the codes work. I just don’t know how to go about making something work the way I want it to. Here’s some of the codes I have tried… See examples below: (BTW, the custom field is named “album_images”)
My website address is (https://headsandhair.com)(1) – it is still in development, so only coming soon page shows right now.

ATTEMPT 1: I added this to functions.php because this example was given by the ACF Gallery plugin. I’m not exactly sure WHAT it does or where it was supposed to go, so I just added it to the Code Snippets plugin.

<?php
    //Get the images ids from the post_metadata
    $images = acf_photo_gallery('album_images', $post->ID);
    //Check if return array has anything in it
    if( count($images) ):
        //Cool, we got some data so now let's loop over it
        foreach($images as $image):
            $id = $image('id'); // The attachment id of the media
            $title = $image('title'); //The title
            $caption= $image('caption'); //The caption
            $full_image_url= $image('full_image_url'); //Full size image url
            $full_image_url = acf_photo_gallery_resize_image($full_image_url, 262, 160); //Resized size to 262px width by 160px height image url
            $thumbnail_image_url= $image('thumbnail_image_url'); //Get the thumbnail size image url 150px by 150px
            $url= $image('url'); //Goto any link when clicked
            $target= $image('target'); //Open normal or new tab
            $alt = get_field('photo_gallery_alt', $id); //Get the alt which is a extra field (See below how to add extra fields)
            $class = get_field('photo_gallery_class', $id); //Get the class which is a extra field (See below how to add extra fields)
?>
<div class="col-xs-6 col-md-3">
    <div class="thumbnail">
        <?php if( !empty($url) ){ ?><a href="https://wordpress.org/plugins/navz-photo-gallery/<?php echo $url; ?>" <?php echo ($target == 'true' )? 'target="_blank"': ''; ?>><?php } ?>
            <img src="https://wordpress.org/plugins/navz-photo-gallery/<?php echo $full_image_url; ?>" alt="<?php echo $title; ?>" title="<?php echo $title; ?>">
        <?php if( !empty($url) ){ ?></a><?php } ?>
    </div>
</div>
<?php endforeach; endif; ?>

I also added this next snippet because it was also shown as an example on the gallery plugin…

acf_photo_gallery(album_images, POST_ID);

Then I tried this one because I saw it on this site somewhere…

function attachment_change_parent($aid,$pid) {
  $update_attachment_post = array(
    'ID'            => $aid,
    'post_parent'   => $pid
  );

  wp_update_post($update_attachment_post);
}

And I have tried several more things, but to no avail. I am just not sure how to do it and the ACF website has no information for it either. If anyone can help steer me in the right direction, that would be great! All I want to do is have the images uploaded with my custom field attach to the post that they are being submitted from or attach to the album being created. It sounds like it should just be easy, but obviously it’s not…Thanks!!!

magento2 – Shipping methods controlled by post codes

I use Magento 2.3.4 and I have 3 shipping methods that are running at the same time but I want them to only display one at a time.

The entire shipping system runs off a set of post codes. for the sake of clarification, these are the post codes:

IV1 1AA,

IV1 1AD,

IV1 1AX,

IV1 1BA,

IV1 1DA,

Secondly, the shipping system runs off a minimum order amount of $1.

Below are the present settings for the 3 shipping methods

1. Table Rate

This runs off a set of post codes and only displays when the available post code is inserted. This works great. no concerns here.

2. Flat Rate

This runs off a minimum order amount of $1 but we want it to display based on the above post codes. In the absence of the above post codes, it shouldn’t display

3. Free Shipping.

This runs off a minimum order amount of $1 but we want it to display based on the above post codes. In the absence of the above post codes, it shouldn’t display.

I tried to use CART RULES but didn’t work out great.

My Request is this… I want an extension that can manage the display of each of the above 3 shipping methods 1 at a time and not all 3 to display at the same time

I need to know of any premium extension that can handle the 3 options above or any method in Magento platform I can use to get it done.

How to take existing post and create a template from it

I have a set of posts that have a basic layout, and I want to set these post settings in the default template. I am not using anything special or custom in the post layout settings: everything is built=in to wordpress. There does not seem to be an easy way to just change the basic settings for the default template in wordpress.

My question is:
How do I change the default post template to match the layout of my current posts?

PLEASE DO NOT ANSWER WITH A BUNCH OF CODE, THIS SHOULD NOT BE NEEDED. IF THERE IS SOMEWHERE IN WORDPRESS TO APPLY THESE SETTINGS, PLEASE SHOW WITH SCREENSHOTS WHERE TO ACCESS THIS AS I AM A TOTAL N00B IN WORDPRESS.

Currently, I have to manually force the sidebar to appear, hide featured image, and hide author name when a post is created. I want the default template to apply these options by default, but I cannot figure out how to edit the default template. I do not know if this is a theme problem (I am using The7).

List auhtor by his custom post count in current taxonomy

I have multi author website. I am trying to show author list ordered by his total post count. I use custom taxonomies and two (2) post types : “news” and “movies”. In the list author name, avatar and post count will displayed. and author url will be author post archive page . Please help me

<?php function get_authors_with($num = 5){
    global $wpdb;
    $term_slug = get_query_var( 'term' );
    $taxonomyName = get_query_var( 'taxonomy' );
    $current_term = get_queried_object( 'slug', $term_slug, $taxonomyName );
    $sub_q = $wpdb->prepare("SELECT * FROM $wpdb->posts
            INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
            INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
            WHERE ($wpdb->term_taxonomy.term_id = %s
            AND $wpdb->term_taxonomy.taxonomy = '%s'
            AND $wpdb->posts.post_type = 'news,movies'
            AND $wpdb->posts.post_status = 'publish')",
        $current_term->term_id,
        $taxonomyName
    );
    $sql = $wpdb->prepare("SELECT $wpdb->posts.post_author, FROM (%s)
            GROUP BY $wpdb->posts.post_author
            HAVING count(*) > %s",
            $sub_q,
            $num
    );
    return $wpdb->get_results($sql);
}
} ?>

vue.js – Array in post converts to string

in html if you do

<form action="" method="post">
  <select multiple name="items[]">
    <option value.... 

the post result will be an array. With vue, if you do

<input type="hidden" name="items[]" v-model="myArray">

you get back an array with one element containing a string “1,2,3”. Essentially, v-model converts into a string on the post request. How can I get it to post an actual array?

visualization – Visualizing directories–a cleaner view of a helpful older post

I am looking to make graphics of a folder hierarchy, and this old post was very helpful. However, this method gives the whole file path for each node, which makes a complete mess in the directory I want to use it. It must not be too tricky, but I cannot figure out how to get just the last part of the path from each node of the tree structure.

In the abstract, if I have tree = a(b(c,d,e),g(h)), I believe I want some way of performing F(tree) = F(a)(F(b)(F(c),F(d),F(e)),F(g)(F(h))). I am struggling to implement.

In the concrete, I mildly adapted the code from the linked question above:

readDir(currentDirectory_, 0) := FileNameTake(currentDirectory);

readDir(currentDirectory_, level_) := 
Module({}, SetDirectory(currentDirectory);
joinedFiles = 
FileNameJoin({currentDirectory, #}) & /@ FileNames();
unjoinedFiles = FileNames();

(*do a logical test;
if the thing in a directory is a directory,*)
perFile(file_) := 
If(DirectoryQ(file),(*condition*)
 file @@ readDir(file, level - 1),(*true*)Sequence @@ {});(*false*)
perFile /@ joinedFiles);

treeDir(dir_) := TreeForm(dir @@ readDir(dir, 11))

treeDir("/Users/vironevaeh/a")

This yields the nice tree, but with the less-nice filepaths built in:
enter image description here

Can I either: (1) apply a function to the nested expression that gives me the first graphic, or (2) rewrite the generative code in another way, to give me the following from the directory input:

enter image description here

Content Writing Service from 500 to 1000 words Article, or blog writer on any topic. for $5

Content Writing Service from 500 to 1000 words Article, or blog writer on any topic.

Are you searching for a professional writer to take care of your SEO article Writings, Content writing, blog writing, blog posts, and

Website content? I have years of writing experience and best practices to handle your writing.

I write TOP NOTCH COPIES for any page – home page, about us, services, blog posts, SEO articles, brochures, and more!

I provide the following services:

  • Creative Writing
  • Write Blog / Article
  • Write through Research
  • On-time delivery
  • 100% Copyscape pass guarantee!
  • Excellent grammar and structure!
  • SEO optimization!
  • 100% Original and Unique Articles
  • Unlimited Revisions
  • Well researched
  • 100% customer satisfaction
  • Friendly customer service

Why Choose Me

Fast Delivery

Quality service guaranteed

Thanks for your time. Feel free to contract with me to discuss your project.

Regards,

Md Monjurul Islam Leon

.

wp query – How to search by a post and a category name on wordpress at the same time?

I wanna change the default behavior of wordpress search engine. Basically, I want to choose between 2 paths when the user informs a term on the search input:

  • Find the posts or custom posts that have that informed term
  • Or find the posts that belong to a taxonomy (or a custom taxonomy) that
    has a name like the informed term

So far, I’m trying to use the hook pre_get_posts but I don’t know how to combine the 2 paths. I did try something like this:

function change_posts_per_page( $query ) {
    $query->set(
        'tax_query', array(
            array(
                'taxonomy' => 'course-category',
                'field'    => 'name',
                'terms'    => get_query_var('s')
            )
    )); 
}

add_action( 'pre_get_posts', 'change_posts_per_page' );

It doesn’t bring the posts with a taxonomy that has the name get_query_var(‘s’). Can someone help me?

How to fix the taxonomy and custom post type slug/url

I have a custom taxonomy and post type.

When I click on a taxonomy item the slug changes to:

http://localhost:8888/mysite/developments/development-name-here/

And that page is using taxonomy-developments.php

But when I click on an item there which is a custom post type item, the url changes to:

http://localhost:8888/mysite/our-properties/my-first-property/

This uses single-property.php

I would have though the url should be:

http://localhost:8888/mysite/developments/development-name-here/my-first-property

Because I want to show the property belonging to that development and thus have the url indicate that.

The post type:

register_post_type('property', array(
    'supports'      => array('title', 'editor', 'thumbnail', 'page-attributes'),
    'rewrite'       => array('slug' => 'our-properties'),
    'has_archive'   => true,
    'public'        => true,
    'show_in_rest'  => true,
    'hierarchical'  => true,
    'labels'        => array(
            'name'         => 'Property',
            'add_new_item' => 'Add New Property',
            'edit_item'    => 'Edit Property', 
            'all_items'    => 'All Properties',
    ),
));

Taxonomy:

register_taxonomy('developments',array('property'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'show_in_rest' => true,
    'rewrite' => array( 'slug' => 'developments' ),
));