You could output them as inline CSS custom properties instead of left/top, and then use those to set the position in either CSS or Javascript.
PHP:
<a class="project" href="https://wordpress.stackexchange.com/questions/345335/<?php the_permalink(); ?>" style="—-x-position: <?php the_field('x'); ?>; —-y-position: <?php the_field('y'); ?>;'">
<p><?php the_field("title"); ?></p>
</a>
CSS:
.project {
top: var(—-x-position);
left: var(—-y-position);
/* or CSS grid: */
grid-row-start: var(—-x-position);
grid-column-start: var(—-y-position);
}
They’re also accessible in JS, if you need them:
var x_position = element.style.getPropertyValue("--x- position");
This will be much more manageable for responsive design since you won’t have to override inline styles with !important
, but inputting such specific x/y values is generally a bad idea and you’re probably better off not intermingling presentation quite so directly with your data.
Related Posts:
- Create a random unique 6 digit number as custom field for custom post type
- when looping through custom post data not appearing
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Order by custom field attribute
- How do I filter a custom post type loop by a field?
- Search that will look in custom field, post title and post content
- How to solve suspected memory issue in custom WordPress loop?
- List events by month
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- Custom post type loops with different page templates
- How do you output custom code between posts in the loop?
- Display custom field of specific post where post title matches variable
- Conditional to modify query results
- wp_query to find posts by year and month
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- How to insert content from another Custom Post type into Post?
- Using several custom fields as custom post title
- Very Slow Page – How to Optimize # of Queries?
- Custom Post Type Loop throws 500 error when used in widget
- How to make sure content doesn’t display if selection is empty
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- Meta Key Value in current-user-only loop
- Push metadata in array
- CPT + CMB2: data not displaying for only first post in loop
- Replace text in post from cvs
- How do i calculate the total of values of custom fields in custom post types?
- Query & Order posts by custom fields
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Custom Tag Description unable to display just below and outside of the Loop
- get_post_meta not working on publishing
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Using custom field content as expression in IF statement [closed]
- Multiple Frontend Filters Using Advanced Custom Fields
- Displaying custom field according to date
- Redirect to another page using contact form 7? [closed]
- Add additional field to custom post_type
- Loop increase number
- Using wp_query to modify the loop in index.php for a CPT
- Control content before and after custom post type loop
- How to conditionally add Custom Post Type to Front Page
- hide specific div on single.php [closed]
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- How do you output an unknown number of images in a custom post type with desired markup?
- Get post content from another section in custom single page
- How do I show my containing my custom field ONLY if there is a set value on that custom field? [closed]
- CPT Repeatable Fields + Undefined Index
- foreach loop inside the loop creating duplicates in output
- Let users upload image(s) to the post from front end
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- Displaying information from custom field on custom post type
- Get post-meta value of all custom-posts – lowest to highest year-count?
- Need help with simple “if statement” checks to output particlular CPT data depending on what client uploads/fills out
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- How do I list a custom field and custom taxonomies for each result in a loop?
- How can I sort the order of multiple custom field values in a custom post type?
- Show the categories the current post has
- How do I ensure that post_type and Taxonomy use the same slug?
- Fetch data from two custom post types and create multidimensional array for output to html table
- Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?
- Create an user checklist system for a course plateform using ACF Pro and ACF Extended
- CPT loop doesn’t seem to account for post date?
- How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)
- Custom fields array to display it monthly
- Alike Shortcode using in Custom Shortcode
- Query custom post type that has a serialized relational advanced custom field value
- Pagination not working in custom post type. Help
- Sort custom post column by generated value?
- How to avoid duplicate posts queried from custom meta?
- How to use posts as tabs in a custom page?
- Accessing download link from the loop with WP Download Manager Pro
- Combine multiple separate lists into one
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Looping to organize and display custom posts by category using PHP and WordPress
- WordPress trying to query two custom types to get child from the parent
- sorting in wp query based on custom field value
- PHP Notice: Unidentified index
- Add active class to foundation 6 tabs while looping categories
- How to make sure, that only the selected post is changing?
- WordPress query in which condition uses custom field
- Error in WP Query. If variable is empty it is displaying previous post value
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- WordPress query posts by custom post type not workng
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Can’t pick up a field created with Advanced Custom Fields
- Get month and day from a Date Picker custom field
- Function not pulling image or text from custom post type
- Show Custom Post Type taxonomy term that matches custom field
- WordPress Custom Post Type and sort by Tags
- If i have custom post type with 5 custom fields do i have to create a new loop to reference each one?
- Select Menu for Custom post Type does not save
- Looping taxonomy in taxonomy?
- loop through custom post-type with two meta_keys
- Query Custom Post Type by Tag
- Loops running into each other
- Get custom post fields and display them
- I want to show image from custom field image on my custom page template