• Im trying to edit the wp_query to display post-link titles only in the form of buttons. im building an information based site for advanced help on complicated electrical controls, and there is 100s of different controls.

    Id like them to be able to scroll down an alphabetical list of post links in the form of buttons. So basically im assigning a class to the wp_query output, and then styling it in CSS. Now, i understand i can do this manually a href etc, but id rather it done automatically considering its constantly being updated with new parts.

    any ideas on how to go about doing this??

    Please disregard my last post. it seems i didnt word it correctly

    • This topic was modified 6 years, 11 months ago by juicyjuke.
    • This topic was modified 6 years, 11 months ago by bcworkz. Reason: Last post linked for ref - will not delete
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Despite the rewording of your question, I believe my original reply is still on point. Essentially, edit the responsible template to output whatever you want from the WP_Query results.

    From how you phrased your question, it seems you do not fully comprehend the limits of what WP_Query does or the role templates play in generating output. WP_Query returns DB data that it found that matches the query vars that were used to compose the SQL query. WP_Query does not output anything. That is the job of template code. Templates typically contain “The Loop” which takes the WP_Query results and steps through each returned post object. Code within the loop is what takes each post object’s data and formats it for output, which is then sent out to the browser.

    The loop code can output as little or as much as it (or you the coder) wants, in any arrangement you want. I advise you to output a list of permalinks that are styled as buttons, but are not true form element buttons. Then clicking this ersatz button will take the user to the single post view of the item.

Viewing 1 replies (of 1 total)
  • The topic ‘Editing wp_query to display posts as Buttons’ is closed to new replies.