List specific custom fields in a post that match post title
-
I am attempting to use this snippet of code in single post.
<ul> <?php global $post; $myposts = get_posts('numberposts=100&offset=0&order=ASC&orderby=post_title&category=24'); foreach($myposts as $post) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>
I have issues due to limited mental capacity and old age.
The above works but, I need to list only the chidren of the current posts category. I was able to do that but, I only want one level down.
I also desired to have my posts in multiple categories. So re-assigning tons of cats is not an option. I also messed with tags to no avail.
My solution is to use custom fields to get the results I need.
Say I have a custom field key “schematics” with a value of “amplifier”. I have several posts with the same combination. Enter them into specific posts based on the list result I want.
How can I use the above code, (or any code) to list only the posts with the same custom field combinations, but wait….. based on the current post?
The problem I am having with categories is that all the children list as well as their children when I use:
if (is_category()) { global $wp_query; $cat_obj = $wp_query->get_queried_object(); $cat_id = $cat_obj->term_id; }
to define category=$cat_id
I figured that’s what custom fields may be used for.
So, what if I titled the post “Schematic” and if the title matches the custom field key (???) it would list all posts with the key “schematic”? I may need to force lowercase before the match as well? (I do a little php and perl javascript). This would allow me to title my posts according to the custom field name in order to set up the match for the query. Right?
In addition, how could I list only those with the custom field combo key=schematics value=amplifier. (“either” “or” or “both”)
This would allow me to show something like:
(these all represent individual posts with the wp generated table of contents below each post.)
——————
(post title) Schematicsdescription yada yada
toc Schematics
1- Amplifiers
2- Test Gear
3- Consumer
4- High Voltage Generators
———————-
select number 1 for instance goes to post
——————-
(post title) Amplifiers-description yada yada
-toc Amplifiers
-1- Tube
-2- Solid State
-3- Hybrid
———————
select number 3
——————-
–Hybrid–description yada yada
–toc Hybrid
–1- Mosfet Power stage
–2- Mosfet Preamp Stage
–3- Bipolar Transistors
–4- IC Stages
———————-
select number 1
——————-
—Mosfet Power Stage—description yada yada
—toc Mosfet Power Stage
—1- 30 watt
—2- 50 Watt
—3- 100 Watt
—4- 200 Watt
———————-
select number 3
——————-
—-100 Watt Hybrid Tube Amplifier—-the schematic and build info
—-toc Shematics (or I can just mod a breadcrumb this part here)
—-1- Amplifiers
—-2- Hybrid
—-3- Mosfet Power Stage
—-4- 100 WattI did read all the related documention but, this is beyond my ability. I’m an amp designer not a coder. 😉
- The topic ‘List specific custom fields in a post that match post title’ is closed to new replies.