Is there a way to save template data into wp_post table? I made a custom template that automatically makes tables and some sentences with the meta-data that users insert in. I wanted to make users choose a template and write in a standardized format with custom field. Users can now just put some text on my custom field (bottom of my post edit page) and click the template on the sidebar, then the contents show on the post page! And …
How can i display multiple posts and posts content on a single URL. Like this https://www.recruitment.guru/ssc/ssc-recruitment/ showing posts on single post page. Please suggest a solution.
There's a way to use ajax to load the content from single.php or a custom .php like ajax-single.php like this page does it: https://yellowimages.com/all/objects/apparel-mockups/ also like them show the URL from the post when you click on the link, I hope somebody can help me with this because I can't find a way to do it yet. EDIT 1: I use the next code on my index.php to load the post titles with the permalink: <div id="single-post-container"></div> <div class="wrap"> <?php …
Not sure exactly what happened, but my site shows the single post content multiple times. Example. Reinstalling the theme didn't help. Also, it's not happening with any other theme, only with the current one. No plugins are active. Not sure what could be the problem.
I have some problems displaying info from my custom meta box in my custom post type single. I'm using Reusable Custom Wordpress Meta Boxes by Tammy Hart. I'm able to display the textfields using this: <?php echo get_post_meta($post->ID, $prefix.'hjemmeside', true); ?> But I can't get the image to display, instead DEBUG is telling me that it is an "Undefined variable: post_meta_data in". Currently I'm using this script: <?php $custom_image = $post_meta_data['image'][0]; echo wp_get_attachment_image($custom_image, 'thumbnail'); ?> Is this wrong? ID for …
I have a custom post type "people". For each person, I can enter the following custom fields: "address", "occupation" and "pictures". In the single-people.php I display the address and the occupation. In addition, this single template contains a gallery button - when the website user clicks on it I want to takes the user to a separate page where only the pictures of the person he just looked at are displayed. How do I achieve that? I cannot just create …
My posts can have any of 2 categories: 1. red 2. blue I have 2 different category pages category-red.php category-blue.php A post can be in both red and blue category If a posts opens from the red category I want it to have a single-red style even if it also belongs to the blue category. is that possible?
I've seen this solution for querying pages based off of template type: Page template query with WP_Query I'm having trouble getting it to work with posts, that are using a "Single Post Template:" rather than a "Template Name:" definition. Here is my code: // query $the_query = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => '_wp_page_template', 'value' => 'single-current.php' ) ) )); Is there a different 'key' I should be using? Something like …
I want to display a fixed banner from the bottom left of the screen. But at the same time, the banner is different for desktops and mobile devices. Please tell me. How can I determine the user's device? For this, can I use the wp_is_mobile function? As I understand it, wp_is_mobile identifies the device by the user agent of the browser. PHP code is very simple. Something like the following? <?php if (wp_is_mobile()):?> <div class="mobile_banner"><img src="mobile.png"></div> <?php else:?><div class="desktop_banner"><img src="desktop.png"></div><?php …
I'm trying to pull a custom post type name/title out for use in the breadcrumb of a single-[cpt].php template file. In the archive-[cpt].php I can use post_type_archive_title() and it echo the name. How would I get this same title in a single view? Thanks! I've trawled though the codex and haven't seen a function, but might have missed it!
I have a single-programs.php page and at the top of this single page I need to list all the entries from the custom post type "programs". Is there a way to give "active" class to this list for the current page (current single post type" ? Here is my code: <?php $args = array( 'numberposts' => -1, 'post_type' => 'programs', 'order' => 'ASC' ); $the_query = new WP_Query( $args ); ?> <?php if( $the_query->have_posts() ): ?> <ul> <?php while( $the_query->have_posts() …
I'm new to WordPress. So, I'm not really sure if it's normal behavior or not but this is bothering me. So, I've my main navigation menu consists of Home | category_1 | Category_2 | Category_3 ... The issue is that whenever I click on a post link it loads as expected but the category under which the post is created also becomes active which I don't want. For example, if I click on a post from category_1 it loads with …
Given this custom post type: register_post_type( 'sample_post_type', [ 'labels' => [ 'name' => _x('Sample Posts', 'post type general name'), 'singular_name' => _x('Sample Post', 'post type singular name'), ], 'public' => true, 'show_in_nav_menus' => false, 'exclude_from_search' => true, ] ); How can I disable the single post view for this particular post type? Displaying a simple 404 is fine, or redirecting to the homepage. Since this is a plugin, I can't create a single-sample_post_type.php file to set up an empty page.
I'm trying to create template for specific category with id 1 for example. The template should be applied to all of the pages belongs to this category. So, it should be something like single-1.php. I tried a lot of solution that I found on the web, including this, but it seems nothing is works for me.
Hi there I have been having trouble with a LinkedIn custom share button. My theme didn't seem to provide one and I like this theme so wanted to create my own. I have gotten as far as getting a window to open that signs you in to LinkedIn and takes you to post about something, I just can't get the code to work so it also inputs the URL of the WordPress single post you are currently visiting. Here is …
I am working on a task where i need to retrive 100s posts under single-page/single-request with their featured images. By using wordpress method of retriving posts and then retrive featured image individually using get_the_post_thumbnail function it takes so much time to load the page. Can someone provide a faster solution for this like retrive posts and featured image under one single query. That should speed up the proccess.
I'm developing my own plugin for my wordpress. I create a shortcode for my plugin and CPT with a custom taxonomy and custom single-CPT. When I try to use the function get_template_part() in my shortcode, the result is a call to a single.php template from the theme. How I can limit where get_template_part can look for files? This is my shortcode: function shortcode_display_products ( $atts ){ global $wpdb; $query = ''; $atts = shortcode_atts( array( 'categories' => '' ), $atts, …
So, I would like to have a back button on the single post page that can be dynamic to the point to where it knows where it is in the query and bring me back to the blog page on the right page number and category and search query string. For example -> "localhost/news-blogs/page/3/?s=news&nb-cat=16" Now I can do this wp_get_referer() If was to stay on that page, but if I click on the next post link then it would just …
I want to display some texts in specific category in single post based on category in wordpress.. how can i do that for example posts in news category display some text.(not all category) Thank you