Skip to main content

All Questions

Filter by
Sorted by
Tagged with
17 votes
3 answers
21k views

Pass PHP variable to javascript

Is there any possibility to pass some PHP variables in javascript so I can use them later? Only in single.php. I heard about wp_enqueue_scripts but with that it is neccesary to declare a path to a JS ...
Sebastian Corneliu Vîrlan's user avatar
14 votes
4 answers
52k views

Get page content using slug

I'm trying to get page content when I only know the slug string. Is there a function for this, or an easy way to do this or is this a case of doing it via SQL? Thanks very much
Alex's user avatar
  • 471
11 votes
4 answers
21k views

Change the_title() of a page dynamically

I'm developing a plugin that doesn't use a custom post type, but separate database tables. It's a plugin that displays a list of courses with links that lead to the different course detail pages, ...
Gchtr's user avatar
  • 460
6 votes
2 answers
16k views

Creating a WordPress admin page without a menu for a plugin

I am writing a plugin, that will list a number of entries from a custom set of tables. I added the main page for the plugin using the following WordPress functions: // Add menu and pages to ...
Greeso's user avatar
  • 2,204
4 votes
2 answers
25k views

Calling a function from functions.php in custom page/ blog post

Is it possible to call a function from functions.php in custom page or blog post? I put simple function in functions.php: function testTest() { echo "Test"; } And called it from the page: <?...
Mary's user avatar
  • 45
4 votes
1 answer
969 views

How to edit the properties of a page programmatically?

I know that I can programmatically create a new page via wp_insert_post setting 'post-type' to 'page.' How do I go about editing that page programmatically? (title, content, slug, etc.) Also, if I ...
Eli's user avatar
  • 69
4 votes
1 answer
4k views

Create page when plugin is activated

I've made so that everytime my plugin is activated it's supposed to create a page. Although i want it to only create the page if it doesn't exist from before. But what it's doing is that it's creating ...
Jake Snake's user avatar
3 votes
1 answer
776 views

How do I approach removing menu items on the fly based on settings in my plugin?

I've started writing a plugin that allows the administrator to select specific pages and set them to be visible only to logged-in users; the plugin optionally applies the restriction to all child ...
Phil Piper's user avatar
2 votes
1 answer
557 views

Set a specific page as 404 - not found via my own plugin

I'm developing a plugin that create some pages and set a specific template for each of these pages. It creates a page in which it sets a template for 404 - not found, how can set this specifc page as ...
icolumbro's user avatar
2 votes
2 answers
429 views

Make custom post type display as a page

I am trying to make my custom post type display on the front end as if it were a page. Depending on the theme, it won't have the date, author, etc... I've looked into creating a template such as '...
Sarathi's user avatar
  • 284
2 votes
1 answer
5k views

Create a custom page template inside my wordpress plugin

I'm developing a Wordpress plugin and I want to create a file to where I want to redirect the user to show some information. I know that a perfect solution for this is using Wordpress custom pages. I'...
user1517951's user avatar
2 votes
1 answer
212 views

Set number of article per number of page

I'm making a timeline using this awesome free theme. As you can see in this theme, it's a timeline separated by "Page". We have "Page 1" with 5 articles, "Page 2" with 5 articles, etc ... I changed ...
Gohmz's user avatar
  • 131
2 votes
1 answer
119 views

Create a Page via plugin

My problem is to show a list of products read from db tables. I know how to read them and I am able to produce the table, but only using a shortcode embedded in a page that I've created via WP. I ...
picus's user avatar
  • 21
2 votes
1 answer
5k views

How to create a dynamic page based on form data with a plugin?

I have a form that users fill out. When they finish, they are redirected to a 3rd party site to set up payment options. After completing the payment process, they are sent back to my site with a ...
Peter G's user avatar
  • 125
1 vote
2 answers
1k views

How can plugins have their own pages?

My plugin needs to introduce a number of interfaces to Wordpress for the public traffic. What is the best way of introducing new interfaces?
Roman's user avatar
  • 637
1 vote
6 answers
500 views

Pages 404 in wordpress

First of all, I am very new to wordpress and know almost nothing about it. When I create the page foo using in wp-admin, I get the message that the page is created. When I click on view page, it 404s....
Joren's user avatar
  • 317
1 vote
1 answer
869 views

Is it possible for a plugin to register a page template file?

Is there a way for a plugin to house page template files and have them available after plugin activation? E.g, I have a plugin that requires specific page page templates to be used, so I'd like ...
darrinb's user avatar
  • 1,236
1 vote
2 answers
22 views

Is there a way to decide from init whether we are on a certain backend page?

On frontend pages I can do something like $currentPostId = url_to_postid($_SERVER['REQUEST_URI']); if ($currentPostId && $currentPostId === $postId) // ... So when I add a ...
inf3rno's user avatar
  • 135
1 vote
1 answer
65 views

Use an empty page to build custom plugin output

I've been Googling for an answer to this and have yet to find much of use. I have seen plugins that will say "pick the page for showing X" and "pick the page for showing y". Then if the page is ...
Matthew Brown aka Lord Matt's user avatar
1 vote
1 answer
577 views

Do action only on certain front end pages?

I am creating a plugin that allows users to insert certain code on their specified page or post of their choice. I have tried doing this: function asdf() { $siteURL = get_site_url() . '/'; $...
sarcastasaur's user avatar
1 vote
2 answers
68 views

Secure Pages Best Practice

I am in process of writing a plugin that has front-end shortcodes that display a user's information/data. If the user is not logged in, I need to redirect to a front-end login page/form. What would ...
clockwiseq's user avatar
1 vote
1 answer
175 views

php page not found for plugin options menu

I'm trying to make an options page for a plugin and i'm getting The requested URL /site/wp-admin/plugin-email.php was not found on this server. every time i press 'Save settings'. Here is my code: ...
Andrei Cojocaru's user avatar
1 vote
0 answers
3k views

Plugin generated virtual pages

I am currently devloping my first WP plugin. This plugin should generate dynamic pages on the fly if a fixed non-existing URL is requested. This means I want my installation to accept addresses like ...
Silicomancer's user avatar
0 votes
2 answers
8k views

Proper way to replace the_content only for pages created by custom plugin

I'm creating a plugin that needs to replace the_content of only two specific pages that it created upon activation. Here is my code: add_filter('the_content', 'emd_content'); function ...
Mark Rummel's user avatar
  • 2,177
0 votes
2 answers
2k views

Dropdown list of pages to get page id to store in plugin options

I need to get a list of all pages in a dropdown list, so I can get the page id of the selected page to store in the options of my plugin. Right now I have: ?> <input name='...
Rikki's user avatar
  • 131
0 votes
1 answer
480 views

Add Password Generator on password protected page

I'm looking for add a password generator with 14 characters on the protected pages like in the picture. I search something like what is used when you create users but for page password.
Samuel's user avatar
  • 354
0 votes
1 answer
67 views

ECHO Executing 4 Times In Head

I have a plugin I created as a test and am running into a bit of trouble. The code is executing 4 times and placing what I echo in the <head> tag of the page. The reason I'm performing an echo ...
clockwiseq's user avatar
0 votes
1 answer
99 views

WordPress pages are not published due to External database connection with WPDB class

I am developing a wordpress plugin that connects to external database, fetch data, and displays it on metabox below page/post editor. I used following code: <?php /** MySQL hostname */ define('...
Jaykumar Patil's user avatar
0 votes
1 answer
36 views

Create page (not the post type) dynamically

I'm working on a custom plugin where the user/customer will be purchasing a ticket (it'll be a woo product) to take a quiz and win some prize... So suppose the URL of a product/quiz would be like ...
Faye D.'s user avatar
  • 126
0 votes
1 answer
63 views

Multiple array for post_content on plugin activation

sorry for my bad English. I want to create multiple pages when activating a plugin. This also works, but how do I get different content in the different pages? if (!current_user_can('activate_plugins')...
EndlessOne's user avatar
0 votes
1 answer
3k views

How to list all images used on a specific page?

How do I list all the image(s) used on a specific WordPress page. I would like it to include the following if possible, Url to image Name of image Url to thumbnail of the image [Edit] I would like ...
Tom's user avatar
  • 143
0 votes
2 answers
131 views

Create fixed static pages

I have inside a theme two important static pages. One is a confirmation page (after signing up for a newsletter) and the other one is a thank-you page. I am using these in various functions and ...
Snowball's user avatar
  • 715
0 votes
1 answer
156 views

Toolbar Hidden in a Virtual Page

I am trying to create a virtual page, but my admin toolbar is not showing up. This is how I am creating the virtual page: functions.php add_action('init', function() { add_rewrite_rule('...
William's user avatar
  • 545
0 votes
1 answer
199 views

Set page to draft on plugin deactivation

Im working on a little plugin that when activated creates a theme page and then a function sets this page to published this is the code i have for published: // function that creates the new ads page ...
MartinJJ's user avatar
  • 1,994
0 votes
0 answers
39 views

How to access the page without registering in wordpress

I have an issue with WordPress. I have the below code and I am getting into the admin menu: public function Create_Menu() { add_menu_page("demoset", "Demoset",...
Naren Verma's user avatar
0 votes
0 answers
64 views

Meta box not displaying on the plugin page

I am working on a plugin and I am creating a meta box on my page using the below code but it's not displaying anything. Any idea where is the issue with my code? class bt_dashboard { function ...
Naren Verma's user avatar
0 votes
0 answers
60 views

Using a Page Template Not in Theme

My plugin creates (on demand via a 'create template' button) a page template that is stored in uploads/plugin-name folder (so it will survive a plugin update). The plugin also creates (again on demand)...
Rick Hellewell's user avatar
0 votes
1 answer
53 views

Load specific page when a custom URL is hit

I'm building a plugin which will basically build a knowledge base dynamically, by retrieving categories, articles, etc. from an external API where all documentation is being kept. I've added a few ...
Daan van den Bergh's user avatar
0 votes
0 answers
350 views

Wordpress Frontend Page using Plugin

I'm trying to create a front-end page using the WordPress custom plugin where I want to create a custom registration page. I have created a boilerplate plugin, where I can only activate and deactivate ...
Ramesh KR's user avatar
  • 101
0 votes
1 answer
29 views

Plugin frontend page design irrespective of the theme used

I am writing a WordPress plugin which will have some front-end pages including inputs, forms, buttons etc. The plugin should be usable with different themes. But I am confused or don't know how to ...
Robert's user avatar
  • 1
0 votes
0 answers
29 views

WordPress: Develop multiple posts with different data

I have a landing page of multiple books as a post, I want to display each book in separated post, in each post has a book name,download link,image and size. All books posts has same design with ...
Zak's user avatar
  • 1
0 votes
0 answers
63 views

Custom non-template page on front end fails to render

I added a link to a custom page on the front end like so: function renderCheckoutLink($links) { $links .= "<li><a href='tradeIns'>Trade Ins</a></li>"; return $links; } ...
Sean D's user avatar
  • 387
0 votes
1 answer
248 views

Get content and send to 3rd party

I've been asked to create a WordPress plugin that will basically show a button on the "edit" and the "new" pages of the admin panel which (when clicking the button) verify an API key (which you can ...
user avatar
0 votes
1 answer
54 views

Choose default template for a page with code

I am creating a page using the wp_insert_code the page is being created just find. I want to choose a default template for the page I am creating which the template is inside plugin folder in a ...
MMTDesigner's user avatar
0 votes
0 answers
33 views

How do I control the list of Pages an author can see?

Using one of the role managers,I enabled Authors to edit/create Pages). The edit/create pages screen shows a tree of all the pages in the system. Is there a way for (beside going into the core) To ...
Itay Moav -Malimovka's user avatar
0 votes
1 answer
39 views

How to add conent (text) to Add New pages form of admin in WordPress

I am new to WordPress. I have created a Shortcode. Now I want to add description of Shortcode to Pages->Add New Page so the user can easily use the Shortcode which I have created. I want that text ...
Abhee's user avatar
  • 103
0 votes
3 answers
7k views

auto create only 1 wp page in activate custom plugin

I am using this code to auto create a page when I activate my plugin.. function insert_page(){ // Create post object $my_post = array( 'post_title' => 'My post', '...
gadss's user avatar
  • 151
0 votes
1 answer
41 views

How to tell which Plugin is displaying?

I'm editing a Wordpress website for a client that was written by someone else. I'm noticing that a video and button are displayed on the home page. I used the Reveal-Template plugin to figure out ...
Rambo8000's user avatar
  • 187
0 votes
1 answer
88 views

Redirect url in plugin to somewhere else?

I am using WP-SNAP Extended! v1.0.0 and I want to use this alphabetical menu as a sub-menu beneath my header. I managed to get the alphabetical menu in place, but now, if I click on a letter, it will ...
user1627363's user avatar
0 votes
1 answer
70 views

Create pages for authors

I have a pretty good question here. I would like to create a hidden page on my wordpress blog for each user as they are registered. I already have most of the code of what needs to be put on the page ...
Ethan Brouwer's user avatar